If you want to specify that the script is to be run by bash when you don't specify a shell to run your script on the command line, you can't have a space before the #!/bin/bash on the 1st line in your script!
If you get into the habit of indenting code in do, then, else, and selections in cases; mistakes like your missing done would be obvious to you.
This User Gave Thanks to Don Cragun For This Post:
Yes, you, too, deserve beautified code: maintainable and more error free!
I have seen people adding comments in SQL 'BEGIN -- {' and 'END --}' so they could use vi's % operator to check balance. Shell do and done, then and fi, case and esac, etc. could use that trick for big entries.
These 2 Users Gave Thanks to DGPickett For This Post:
The program is written in perl and I am using a shell to make it easier for others to use. Thanks .
Understood. If system() is the very last thing a Perl program does, you might try exec() instead, for some time and resource savings -- perl will replace itself, effectively quitting early, instead of creating a brand new process, and the program which launched it will end up waiting for the new shell.
You could also put exec inside the exec() block informing the shell to do the same thing for further savings -- the process gets replaced twice, the program which launches it ends up just waiting for perl, not shell waiting for perl waiting for shell waiting for perl. The amount of time that saves can be surprising.
That would end up looking something like
...if that looks torturous, consider: It's actually far more direct than was written :P
Last edited by Corona688; 10-23-2014 at 07:41 PM..
All your sugesstions are valid and will help, but I can not seem where to put the done. If I put it after the
to close the first
I get:
If I put it before the
to close the first
I get: Is this batch repeated. Thanks .
I suggested to replace system() with exec(), not wrap it in yet another block.
And my suggestion wasn't entirely serious. The point was to illustrate how many completely unnecessary processes you are running and how much extra complexity to use something that was supposed to be simple. A better solution would be to strip out most of that code and just write it in shell in the first place.
Last edited by Corona688; 10-24-2014 at 12:21 PM..
Hi Friends,
I have a script like this
cat script
#!/bin/bash
#Name: name
#Task: name
#$ -e /path/to/error/logfile/err.log
#$ -o /path/to/output/logfile/out.log
I have a list of commands like this
cat commands
cat 1.txt > 2.txt
cat 23.bed > 789.alm
zcat 1.gz > 1.txt (3 Replies)
Dear Gurus,
I had hundreds of equipments which i can only use SSH to login and retrieve informations. Thus, how should i do that? eg:ssh batch
@ echo off
ssh <server1>@10.168.1.1
ECHO testing1
exit
ssh <server2>@10.168.1.2
ECHO testing2
exit
Can the above method used? :) (6 Replies)
Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below.
I am on a solaris server btw.
Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose.
... (2 Replies)
I have a file named xyz.txt with the contents
eg:
abc/pluto/tag/ver_1.0(b0123)
abc/pippo/tag/ver_1.0(b0124)
.
and so on
I need a script which read one by one the enteries from the file xyz.txt
create folders pluto/ver_1.0(b0123) and pippo/ver_1.0(b0124) ans so on
and run a command svn... (1 Reply)
Hi all
I am using tru64 Unix and I want a ready batch file which makes me to change all user passwords at the same time ,instead of changing everyone separately.
Please could anyone help me to do that.
bye. (1 Reply)
hi all,
given a path, for example :
/<pwd>/artist/album/
what i would like to do is to rename the album directory like that :
/<pwd>/artist/artist | album/
and i would like to do the latter for all the "artist" directories
and for all the "album" directories that belong to an artist
... (4 Replies)
what is a command to call a batch file from a c++ program
when called with the argument which is a text file, then how to print that text file on a printer.
please help me with code if possible (3 Replies)
my requirment is
i have to call a batch file from a c++ program
that batch file is called with the argument as print.txt
print.txt is a text file which should get printed on printer (any printer) when a batch file call is made
1) how to call a batch file in c++
2) how to print the text... (1 Reply)
Hi All
I have a need due time constraint to issue the mail command in background. I have a script that sends a message to a mail address as follows :-
echo "$MLINE" | mail -s "$HOST - $TEXT" name@co.com &
The script runs frequently and I check to see if the script is active and if it is , it... (5 Replies)
example test1 will have m1234567.12a
I would like to rename in batch but I don't Please help me on this.
cd /a1/a2/a3
test1=$(basename /a1/a2/a3/*.*) >> /tmp/t
echo $test1
echo "Extracting 8 th position" >> /tmp/t2
awk '{print substr($1,8,1); }' $test1 >> /tmp/t3
echo "extraction ... (3 Replies)