Hi Guys, I want to create a shell script to run multiple jobs in sequence.
Explaination -
If I were to run each jobs individually I would have gone to folder - "abin"(where my shellscript is place) as follows
cd abin
abin > runappeng.sh abc001
Now, I have list of programs which are like abc001 thru abc010.
So, my requirement is how to run the script to do this. Waht should I name it, so that when I go to abin folder and put scipt name as testmul.sh. It will intiate the sequence of programs getting executed
and their status on the front end.
As to the status, the variable $? contains the return code of the previous command, so you could put after each line echo "abc001 finished with a return code of $?"
Sorry, abt asking such a simple question....but I seriously dont know how to do that. New kid on the block.
Step I did -
I prepared a file with
name as "test1.sh". Inside that file scripts were as follows -
runappeng.sh abc001
runappeng.sh abc002
runappeng.sh abc003.
Now when I went to Home/abin > test1.sh
It thrown error -
ksh: Test1.sh: cannot execute
So, I am not sure where I am going wrong or what I am missing.
Chaits, as shell_life indicates, your file permissions does not let you to execute that file. if you do a ls -l yourfile you can see the permissions at the beginning of the line, something like -rwxrwxrwx . The gist of it is that there are 3 sets of permissions -- owner, group and other ('other' is anyone who isn't the owner or in the group). There are 3 options available -- (r)ead, (w)rite and e(x)ecute -- rwx. In order for you to run a file, it must be executable, e.g., the x flag must be set for whatever level of permission you have (if you're the owner, in the group or neither). 777 means rwxrwxrwx, which is the most permissive permission.
You use chmod to modify the access permissions on the file. We use numbers (aka, 777) to represent these flags. the 'r' is worth 4, the 'w' is worth 2 and the x is worth '1'. So, 4 + 2 + 1 = 7, and three sevens in a row means read, write, execute for owner, group and other. If you had permissions of 754, the owner would have read, write, execute, the group would have read and execute and other people would only have read.
You can look at this tutorial for more details on it.