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

learn more… | top users | synonyms (2)

0
votes
0answers
36 views

get time of file in inotifywait tool

for this script: inotifywait -m /path -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" # do something with the ...
1
vote
1answer
35 views

TCL script try catch

I have a TCL script that sets a number of variables and reads several files. The last file it reads may contain sensitive information, so I need to make sure this file gets deleted even if an error ...
3
votes
2answers
81 views

Loop in WildCard as Input of Script

I want to use my script on many files sometimes. I used this for the purpose: for etminput in $1 do #process done But this just gives the first input. How can I do the process on every ...
1
vote
2answers
31 views

Livesearch with first 10 matches as preview for zsh-history?

I have seen a history-livesearch with a preview, that shows the 10 first matches in the history in a list below the BUFFER-line, which is updated on every keystroke, and acts like the standard ctrl+r ...
2
votes
0answers
15 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. ...
1
vote
2answers
51 views

Querying a remote POP3 Mail server using BASH

I'd like to connect to our mail server via POP3, look for a certain pass phrase in the subject and if found then run a script. How can I achieve this with BASH other than awkwardly scripting Telnet? ...
4
votes
1answer
75 views

Bash script for scp interpreting tilde (~) too soon

So, I just started a new C++ class that requires me to program in a Linux environment. I don't have Linux installed on my machine, but I do have OS X and I can ssh into a linux machine in the lab at ...
0
votes
1answer
20 views

Header about MIME email

Morning, can some body help me about MIME email? I want to send HTML email like this: MIME-Version: 1.0 Content-type: multipart/alternative; boundary=lazuardi --lazuardi After that email. I have ...
0
votes
1answer
44 views

Is there a way to create a new file and insert text into this file all with bash? [closed]

I need to change and create several configuration files for some kiosks at work, is there a way to do this with a single bash script? I've heard about SED but the documentation is confusing, could ...
2
votes
2answers
88 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
0
votes
2answers
71 views

Intro to shell scripts with basic application: how do I set my computer to make an archive of a particular folder every day?

I've got a situation where I need to give some people access to my dropbox folder. Already so far they have deleted huge folders full of important data. Their computer skills could use a bit of ...
0
votes
0answers
37 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...
3
votes
1answer
82 views

Login automatically as root

I am working with a board and when it finishes the boot, appears the login. What I want to do is login as root but automatically. I mean I want to do that when boot is finish, I can see the prompt, ...
1
vote
0answers
28 views

Run startx & automatically embedded syste,

I am working with a board in which I run my application which use th graphical mode. Everything works perfect. I start the graphical mode like this: startx & and then I run my application like ...
0
votes
2answers
33 views

How to pass argument with spaces to a shell script function? [duplicate]

I'm trying to pass multiple argument to a function, but one of them is consist of two words and I want shell function to deal with it as one arg: args=("$@") function(){ echo ${args[0]} echo ...
2
votes
3answers
111 views

Script to ssh and run a command doesn't work

Below is the script. I wanted to login several servers and check for the kernel version. #!/bin/bash #input server names line by line in server.txt cat server.txt | while read line do sshpass -p ...
2
votes
1answer
24 views

ionCube shell script gives error

I have this shell script to install ionCube loader: if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi echo "Welcome to this script to install the ionCube loader on CentOS!" cd ...
3
votes
1answer
90 views

Tokenize string from $REPLY in bash script

This is my first post, and I have no idea how I managed anything before StackExchage, Google, Wiki, GNU, Internet, the list goes on :) I am trying to find a way to construct a SQL database generator ...
2
votes
1answer
18 views

Comparison of columns in two files and appending the first file

I need a help on this :- I have a file : emp.txt 21356 suresh 12/12/2012 23511 ramesh 11/06/2011 31456 biswajit 09/08/2013 53134 archan 06/02/2009 first field:- employee id, 2nd field is name and ...
3
votes
1answer
28 views

Service script calls another script with variables

I have a simple service script tomcat7 in /etc/init.d/ to start and stop my app server (tomcat) under the tomcat user. On RHEL6. #!/bin/bash # description: Tomcat Start Stop # processname: tomcat # ...
3
votes
5answers
167 views

efficient cross-os file size shell function

I'm looking for a simpler way to have a cross-os-unix file size check. I could use wc -c but I'm concerned the performance may suck on large files (I'm assuming it just counts chars and doesn't do a ...
1
vote
3answers
118 views

Calling a function which calls another function with a for loop

I am calling a function with a for loop and saving the returned value to a variable. When I run the code, I get a command not found error. What is wrong? #!/bin/bash check_1() { x_$1=$(check_2 ...
0
votes
1answer
13 views

Cannot access elements of an array in zsh

I am trying to write a script in zsh and I need to make use of arrays in order to achieve my aim in an elegant way. After reading some information over the Net, I tried to implement and access the ...
3
votes
1answer
187 views

How do I fill my password automatically from .bash_profile when running command as sudo?

I know I could just put something like sudo mypassword in my .bash_profile, but I don't want to run every command as root. I want password to autofill under following circumstances: only the ...
3
votes
2answers
39 views

Problem with read variable from AWK

I'm trying to get memory info by this command: #!/bin/bash set -x cat /proc/meminfo | grep "MemFree" | tail -n 1 | awk '{ print $2 $4 }' | read numA numB echo $numA I'm getting this + awk '{ print ...
3
votes
1answer
39 views

Error when calling a script from inside another script

I'm writing a couple of scripts to start vlc and periodically update its playlist. The update_pls.sh works well if I execute it from prompt, but when I call it from start_vlc.sh, in each for cycle I ...
4
votes
3answers
198 views

Running commands on multiple servers [duplicate]

I want to execute a process on multiple servers. I am using the following wrapper script. The script moves to servers one at a time. I would like to change it so it can execute on multiple servers. ...
2
votes
0answers
93 views

How to write a shell script to run multiple command in different screen sessions?

My goal is to write a zsh script in order to create multiple screen sessions and run separate commands on each of them. I would also like to check at the beginning of my script if there are any ...
1
vote
2answers
103 views

I get a “command not found” error, though the script file is shown by “ls”

I want to run yii console commands in shell. I run protected/yiic in the console, yet it fails, yielding -bash: yiic: command not found What's the problem? See the shell commands and responses I ...
0
votes
0answers
22 views

AWS EMR Bootstrap

I need to write a bootstrap action file for my AWS EMR that runs during provisioning and performs: Install latest R version from: http://cran.us.r-project.org Install ‘lme4’ package (and all of its ...
0
votes
2answers
93 views

How to kill a process running in specific script

I have two script files running simultaneously. I just need to kill the java process running in one script without affecting the java process in the another one.
0
votes
0answers
18 views

Mutt multi content type

Good afternoon I want to send multiple content_type with mutt. Can I do that? Here is my code : mutt -e "set content_type=text/html" -e "set content_type=text/plain" someone@mail.com -s "Multi ...
2
votes
2answers
130 views

to compare two fields in two different files

In file1, I have 1023M BLD 123G DEV 945K Deployment 4899 INT In file2, I have 1.2G BLD 123G DEV 345M Deployment 499M INT I wanted to compare the first field of file1 with first ...
1
vote
1answer
35 views

How could i flip content of a binary file with bash commands

I was wondering if it's possible to do bitwise conversion on a binary file, with bash commands, (in my case bitwise negation).
0
votes
2answers
51 views

init.d script is not starting under virtualbox

The script is in /etc/init.d: #!/bin/bash VMUSER=myname CURRDATE=(`date +"%m-%d-%Y"` + `date +"%H:%M:%S"`) CURRTIME=(`date +"%X"`) FILE=/home/myname/log/vm-services.log VBPATH=/usr/bin start(){ ...
0
votes
1answer
60 views

Problems copying files with spaces inside the file name in a bash script [duplicate]

I have the following function inside a BASH script (running under Ubuntu 12.x), which would copy over a file with spaces inside the file name. It's not working. I've tried many different combinations, ...
2
votes
1answer
40 views

Killing multiple instances of the script from the script itself

I've couple instances of script.sh running in parallel, doing the same thing, running in background. I'm trying to use a function to kill all the current running scripts when executed. So, for ...
1
vote
1answer
63 views

Why doesn't this piped script work?

#!/bin/bash rm out mkfifo out nc -l 8080 < out | while read line do echo hello > out echo $line done If I browse to the IP of the machine this script is running on (using port ...
5
votes
4answers
439 views

How can I “lazily” read output from xrandr?

I have a bash script that I use to adjust my monitor brightness that uses xrandr --verbose to get the current brightness. It works fine, but using xrandr is kind of slow on my machine, as you can see ...
1
vote
1answer
84 views

Command-line parameters in bash script not recognised

I use Debian (Raspbian) Wheezy. If this command line works fine: smsd -c sms/out -i 60 -0 -f sms/smsd.log and this alias also works fine: bsmsd='smsd -c sms/out -i 60 -0 -f sms/smsd.log' then ...
5
votes
4answers
221 views

How to replace all the first occurences in matched lines with incremental number?

I have a file like this ... 1562 first part 1563 H col3 H col4 1564 H col3 H col4 ... 3241 H col3 H col4 3242 third part ... I want to replace only the first H in every line to H#, with ...
1
vote
3answers
99 views

How can I get the pid of a process started this way

#!/bin/bash mkfifo /var/run/out while true do cat /var/run/out | nc -l 8080 > >( while read line do do some stuff done ) done How can I get the pid ...
1
vote
1answer
119 views

How can I kill child processes with start-stop-daemon?

I'm writing a simple web server using nc and bash. It looks like this: #!/bin/bash rm -f /var/run/streamman/out mkfifo /var/run/streamman/out trap "rm -f /var/run/streamman/out" EXIT while true do ...
1
vote
2answers
57 views

How do I validate a settings(ini) file for the values expected using bash?

After I check if the ini file exists where it is expected to be, which I've learned how to do, I would like to check the file for proper formatting. I'd like to validate any number of "site" entries ...
-1
votes
1answer
45 views

Shell scripting enthusiast [closed]

This may sound generic and non technical to many but i can use some quality advice here. I am an technical support engineer who happens to be interested in shell scripting. My job does not need me to ...
0
votes
2answers
53 views

Editing /etc/init.d/mysql to remove mysql.sock automatically

I am running MySQL on a CentOS release 6.5 (Final) virtual machine. It is used for testing Joomla. The phyiscal host reboots frequently, which is fine. The VM, however, does not perform a clean ...
-2
votes
2answers
37 views

Identifier must be declared [closed]

Hi I am new to Shell scripting , and I am facing this issue for days, can someone help me out? my snippet : filename='somefile_Connectivity_12345.CSV' trimfilename= echo $filename| cut -d'_' -f ...
2
votes
2answers
111 views

How parse a log file for a string, and when found search backwards for another string

I use the following command to parse a log file for a particular string. Then I search backwards in the log to find the data I really want. The problem as in the example below, I am only going back ...
4
votes
2answers
74 views

Using $ in a password

Lets assume that password of my server is Abcd$1234 I am trying to ftp a file from other server to my server using the following in shell script ftp -inv (IP) << EOF user Username Abcd$1234 ...
3
votes
1answer
183 views

How does the colon sign and dollar question mark combine in sh?

The "colon sign" and the "dollar question mark" can be combined to check if a sh script does have an argument and assigns it directly to a variable of interest: cmd=${1:? "Usage: $0 ...