Shell Scripting Newbie


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Scripting Newbie
# 1  
Old 07-26-2011
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
# 2  
Old 07-26-2011
Can't you just create a file:
Code:
runappeng.sh abc001
runappeng.sh abc002
...
runappeng.sh abc010

and run it?
# 3  
Old 07-26-2011
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 $?"
# 4  
Old 07-26-2011
Shell Scripting Newbie

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.
# 5  
Old 07-26-2011
Code:
chmod 777 test1.sh

# 6  
Old 07-26-2011
Quote:
Now when I went to Home/abin > test1.sh
It thrown error -
ksh: Test1.sh: cannot execute
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 ----------

Quote:
Originally Posted by Shell_Life
Code:
chmod 777 test1.sh

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.
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 07-26-2011
Corona688, sure it could if it's like

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting newbie problem

I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax, I'm guessing in the bolded line? ... (9 Replies)
Discussion started by: Tibor63
9 Replies

2. Shell Programming and Scripting

Newbie Question: What is php shell scripting?

I know php is a Web Development language but what does it have to do with shell scripting. I might be wrong about php. Is there a CLI? How do I make one and how does it work? Please don't answer these if you have any books on this. Please give names of good beginner books for php shell scripting... (3 Replies)
Discussion started by: orszhak
3 Replies

3. Shell Programming and Scripting

Scripting needed for newbie

Hi, I am newbie in shell scripting I have a file name like simple.txt which comes from Mainframe systems onto windows dir every 15 minutes daily. File name is same. Every 15 minutes it updates. I need to write shell script to check if the file arrived every 15 min or not. If the new file... (4 Replies)
Discussion started by: chinniforu2003
4 Replies

4. Shell Programming and Scripting

Shell Scripting NEWBIE - Need Help

Could someone please recommend a very good shell scripting book for me. I would be starting a new job that would require a very good understanding of shell scripting. Please help. (3 Replies)
Discussion started by: ayoka
3 Replies

5. Shell Programming and Scripting

scripting newbie... some help please?

hi all, i am just getting in to bash scripting, so don't be too harsh... i've created this little backup script, and it's just awfull... ugly, doesn't work like I want it to, the works. anyways, i was hoping some of you might help me improve it and learn a little in the process. what i... (13 Replies)
Discussion started by: jmd9qs
13 Replies

6. Shell Programming and Scripting

scripting newbie needs help

I have written a script that will email a generic user when a device is "offline". I would like to enhance this by having the script lookup a contact's email and automatically add it to the MAIL_LIST. I am trying to lookup and return data based on a field common in two files File 1 ... (0 Replies)
Discussion started by: irishluck66
0 Replies

7. Shell Programming and Scripting

Scripting Newbie

Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path. I can not get anything I write to run. Please help. (5 Replies)
Discussion started by: Kymmers7
5 Replies

8. UNIX for Dummies Questions & Answers

Shell Scripting Newbie

I'm relatively new at this scripting game, just need to learn some basic stuff for data handling. My current need is to write a script that loops through a textfile of filenames, and for each file removes the first line and re-writes that file to a new name. In fact I could do with knowing... (1 Reply)
Discussion started by: mattyjim2
1 Replies

9. Shell Programming and Scripting

Shell scripting newbie - please be gentle.

Hello Gurus, Here's my problem, I have log files that are created automatically once a day by a feature of NetBackup called Vault. I usually move these files manually to a different location so I can FTP them later, however I know that this can be automated and so here's the info: When vault... (2 Replies)
Discussion started by: charliemp3
2 Replies

10. UNIX for Dummies Questions & Answers

shell scripting newbie question

Hi all! I'm a newbie to shell scripting. I want to create a script that will store a line from a text file in a variable so I can then use it to open firefox with that text in the address bar (the text file contains a list of addresses). I have tried the following: #!/bin/sh a='sed -n 2p... (2 Replies)
Discussion started by: jazzman
2 Replies
Login or Register to Ask a Question