Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

4
votes
0answers
914 views

Number comparisons in BusyBox ash

I have the following script that extracts data from the EXIF command on my BusyBox ash-based system. I parse the date tag from the end of the file and use case as a final check to ensure the format ...
3
votes
0answers
77 views

wait bash-builtin burns a CPU at 100 percent

Occurs at least on GNU bash version 4.3.42 x86_64 && GNU bash version 4.3.11 x86_64 I use sleep & wait $! instead of a simple sleep for getting an interruptible sleep by a signal (as ...
3
votes
0answers
71 views

Memoizing/caching command line output

I have a bash script I use to run a few python and C++ programs in a sequence. Each program takes in some input parameters which I define in the bash script. So as an example I run the program like ...
3
votes
0answers
115 views

Get notified from avahi

After looking for a zero-conf browser valid implementation I realised that inside my linux machine (ubuntu) I already have avahi and typing: avahi-browse -alr I get a complete list of all devices ...
3
votes
0answers
241 views

Securing a script a little more

I currently have the following script which works fine: #!/bin/sh user="$(zenity --entry --title="Username" --text="Username")" pass="$(zenity --password --title="Password" --text="Password")" ...
3
votes
0answers
196 views

Understanding line numbers reported when using eval

Okay, so I'm stuck working with a shell script that needs to use eval (I know, I know, ultimate evil etc…) however I'm having difficulty debugging some of the line numbers being thrown out by errors. ...
2
votes
0answers
50 views

Bash completion extra space when adding file directory

I have a script for extending bash-completion for certain commands. If I type command1 and do a tab, it should auto-complete with a file directory (and the files). It works fine expect for one ...
2
votes
0answers
72 views

Getting script's real absolute path in /bin/sh

I'm looking for a way to get the real absolute path to the current /bin/sh script. It should work for situations like this one: /path/to/symlink/in/PATH/somescript -> ../../Package/current/...
2
votes
0answers
28 views

Shell script which runs mono_service.exe as a background task

When I start an Ubuntu Linux 16.04 process with /usr/lib/4.5/mono_service.exe AudioRecorder.exe it returns right way. But, when I write a bash shell script with one line: exec /usr/lib/4.5/...
2
votes
0answers
46 views

How to get the executed command of a process which has completed successfully using the PID?

I have small script, abc.ksh that takes 3 parameter e.g abc.ksh ${a} ${b} ${c} I will read from a config file with 'n' no of entires and I will execute abc.ksh 'n' times in parallel using a for loop. ...
2
votes
0answers
33 views

Producing the next available filename for a pattern (02-output.log etc)

I can use mktemp(1) within a shell script to make a temporary file in a directory with a suitable suffix & prefix. Is there a command that, given a pattern (e.g. NN-output.log) will look for 01-...
2
votes
0answers
21 views

Using a web browser to generate a gallery/slideshow from local files

I'm trying to see how far I can go with using a web browser for various tasks vs. native apps. One of these tasks is selecting a group of local image files and generate a preview/gallery/slideshow in ...
2
votes
0answers
43 views

i3status script that change its text by itself

I am trying to add a block for rss the latest news in my status bar. The news is composed by a title and a description. The full text doesn't fit in the status bar, so I would like to make it read ...
2
votes
0answers
36 views

How to properly use $_ inside a tcsh script sourced from another tcsh script?

I try to retrieve the result from $_ inside a tcsh script itself sourced by another tcsh script (I'll refer to them respectively as the inner and outer script). But $_ is not set with the value I ...
2
votes
0answers
118 views

How to count nodes and get attribute value without using xpath

Currently I have a shell script like this: LOGIN=`curl 'https://www.ponta.jp/u/LWAS900/SLWAS900010.htm' -sS | grep '<input type="hidden" name\|<form\|</form'` for i in $(seq $(printf "$...
2
votes
0answers
113 views

How do I write a Bash script to autoadjust the screen resolution of Enlightenment 20 running under VirtualBox?

I have noticed that VirtualBox guest additions fails to autoadjust the screen resolution of Enlightenment 20 on a few different platforms (including Arch Linux, Lubuntu and openSUSE Tumbleweed), see ...
2
votes
0answers
22 views

On using $hash_array[$(global_alias)]

Identical code works on one system, fails on another: % zsh --version zsh 5.0.7 (x86_64-pc-linux-gnu) % typeset -A frobozz % alias -g foo='echo xyz' % frobozz[$(foo)]=9 % echo ${(kv)frobozz} xyz 9 ...
2
votes
0answers
57 views

How to avoid namespace collisions/pollution in a script meant to be sourced?

I want to implement a script foo.sh that culminates in the an execution of a command bar (with some arguments). The command bar modifies the current shell environment, which means that foo.sh must be ...
2
votes
0answers
41 views

How do I process new additions to logs

I know that I can use a few tools like tail and less to view the newest additions to a growing log file. What I want to do, though, is run some sort of script at regular intervals (like cron) on the ...
2
votes
0answers
282 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
2
votes
0answers
130 views

Generate array of strings combined with number

I would like to generate a local array in a shell/bash script that consists of the following elements: JF-1998, JF-1999, JF-2000,... , JF-2011. That is, a string JF- combined with the years from 1998 ...
2
votes
0answers
87 views

“login -qf” as root results in “Login incorrect” error

I'm trying to install pow on an OS X machine.* Some of pow's components have to run as root, so part of the setup process involves running an installation script with sudo. The problem is, this setup ...
2
votes
0answers
105 views

Copy folders at once

I want to copy a large number of folders at once not one by one. Is it correct to use the following code ? Is it helping to run the command cp for all the folders i at once? #!/bin/bash foreach i in $...
2
votes
0answers
347 views

Udev running hibernation script

I have this udev rule that launches a script when the battery level is 5% or below: $ cat /etc/udev/rules.d/90-lowbat.rules: SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="...
2
votes
0answers
75 views

unbuffer/expect swallows the rcode when its child is signaled

unbuffer is able to pass along the return code of a process under normal circumstance, but if the process you are unbuffering is killed, for instance with a segfault, I see $? as 0 while I expect 139. ...
2
votes
0answers
199 views

background gui process in shell script

In the below script, ivfstudio commands open a gui. Even launched as a background process, I need to close it first so that the next commands are executed. How to make it "really background" ? #!/bin/...
2
votes
0answers
191 views

Shell scripts for the database logs

The actual log file will be like this $ cat file1.log time=2014-07-23 23:56:28 GMT, user=[unknown], db=[unknown], host= pid=28254 LOG: time=2014-07-23 23:56:28 GMT, user=portalman, db=ss, host=172....
2
votes
0answers
99 views

Scripts cannot run simultaneously on startup

I want two scripts (Server_drive, Server_video_boot) running on startup, but there is conflict between them. Specifically, there is always running the script with the lower priority. I tried with many ...
2
votes
0answers
5k views

Creating multicast join for tcpdump captures

I want to write a linux shell script which will capture specific multicast traffic. Specific as in, I want to create a pcap file that has all the traffic for one specific multicast group/port. Here ...
2
votes
0answers
254 views

Check via Shell-script if server currently streams via dlna

Currently I'm running uShare to stream videos from my home-server via DLNA to the TV. On the server there is also running a bash-script which checks if a user is connected via ssh or Samba. If this is ...
2
votes
0answers
3k views

Script stops command in it with exit 0

When I write a bash script similar to this on RHEL 6, if [ "$2" = "" ] ; then echo vip.start: ERROR: no NIC specified echo vip.start: Need IP and base interface name exit 1 fi case "$1" ...
2
votes
0answers
119 views

how to list blocked connections events by the firewall?

So, I used firestarter that had logged blocked connections events with some useful details (but it is not being updated and I found somewhat unsafe as any moment we could click to deactivate the ...
2
votes
0answers
706 views

Validate Password for user account from shell script

Application is for a multiple server standardization script Looking for a way in a shell script to check if the password for an OS account (AIX) matches a standardized plain text password. The ...
1
vote
0answers
32 views

mutt doesn't run as a cron job wrapped in a bash script

mutt runs correctly like this: $ cat /home/user/test this is a test $ mutt -s "test" to@destination.org </home/user/test If I put this inside a bash script (stored in tmp1): #!/bin/bash /usr/...
1
vote
0answers
31 views

evaluating dual blocking commands in a bash condition statement

I am attempting to write a loop that refreshes a terminal either 1. when the file(s) have been modified, or 2. When user input is detected second interval. I know how to do one at a time, like so: ...
1
vote
0answers
31 views

How to run Firefox from script?

I can run Firefox without a desktop environment by running the following commands in succession in a virtual console: sudo pkill lightdm X &>/dev/null & DISPLAY=:0 compiz &>/dev/...
1
vote
0answers
18 views

GTK gtkdialog window to make a link

I'm trying to make a pop window that lets you select a dir . in the back ground this will make a link to that dir. im using bash scripting and gtkdialog /home/rich/movies --> /home/rich/content/...
1
vote
0answers
11 views

Fluxbox, how to launch specific instance of application in a workspace (from cli)

This almost does what I want Fluxbox, how to launch some applications in a specific workspace at startup but not quite. I want to be able to save the position and workspace of a specific instance of ...
1
vote
0answers
28 views

Avoid starvation using flock with 2 process with write and read lock

I have two scripts let's call them script1 and script2. The script1 is scheduled every 2 minutes and it takes 4 minutes to execute the script2 is scheduled every 30 minutes and it takes 4 minutes to ...
1
vote
0answers
27 views

Bash check if firefox use internet

I want to check how much internet use Firefox with a shell script. Here I found good examples to see performances. #!/bin/sh free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*...
1
vote
0answers
13 views

Avoid delays from network calls in logon and logoff scripts

I'm trying to tune some scripts in my test environment. My test environment is specialized and it exists to test software. The software includes Botan, Cryptlib, Crypto++ and OpenSSL. Whenever I log ...
1
vote
0answers
60 views

What is the difference between autossh and ssh that is put in a while loop?

From this website it says that: Autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic. But I really can't see the ...
1
vote
0answers
35 views

How to evaluate commands on the given node of cluster by using plink?

Despite plink (putty link, which provides remote evaluation of commands on remote cluster by using ssh) is Windows application, I hope that You will help me in this question. I have the remote ...
1
vote
0answers
28 views

American Fuzzy Lop run test program as unprivileged user or in chroot

I'm attempting to test tcsh on OS X with American Fuzzy Lop as an exercise, but don't want to accidentally clobber any useful files on my system. Knowing essentially nothing about fuzz testing, I did ...
1
vote
0answers
309 views

Start vino-server in Ubuntu 16.04 lts

I'm trying to raise vino-server in Ubuntu 16.04 but I could not. I am using this script and let me start by terminal: # /etc/init.d/vino-server.sh start but not as a cronjob: @reboot /etc/init.d/...
1
vote
0answers
111 views

Changing permissions of the file, while using sftp command in a shell script

How can I change the permissions of the file/command, while using the sftp command via a shell script? My sftp connection is established, but it fails while executing the chmod command. As of now, I ...
1
vote
0answers
14 views

Linux Mint Corners Musical Sequence Associative Array

I am writing a script which uses hot corners to play specific musical notes when hovering in corners, and depending on the musical sequence to execute a specific command. The script is called with ...
1
vote
0answers
26 views

pmap hangs on OOM process

I did attempt a search, but there doesn't appear to be much out there on pmap so here goes. I have a script that works with WebLogic instances to gather data on them which we can send to our Devs for ...
1
vote
0answers
64 views

How to make excel interpret Chinese characters in CSV file

I am sending a report from a unix shell script that contains chinese characters. When I open the CSV report in plaintext editor like textmate I can see the chinese characters but when I open CSV ...
1
vote
0answers
28 views

dialog menu to display files, select one of them and then able to delete it

I want to be able to display files under a given directory, then select one of the files and be able to delete it. Here's what I've found so far. Can anybody help? let i=0 # define counting variable ...