Shell Scripting Newbie

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.

-Rgds,
Chaits

Can't you just create a file:

runappeng.sh abc001
runappeng.sh abc002
...
runappeng.sh abc010

and run it?

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.

chmod 777 test1.sh

That can't be what you actually typed. What did you type?

---------- Post updated at 02:13 PM ---------- Previous update was at 02:12 PM ----------

777 is not the magic sledgehammer to solve all permission problems. These numbers mean things, and 777 has further implications than you realize.

777 allows anything at all to modify the file! How about 770, or 750.

1 Like

Corona688, sure it could if it's like

Home/abin > test1.sh
ksh: Test1.sh: cannot execute

and he has his current directory in his PATH.

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.

No it wouldn't, since that attempts to write to test2.sh, not execute it.

'Home/abin > ' being PS1 and PS2, I mean.