The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing arguments from shell to java kenpeter UNIX for Dummies Questions & Answers 3 05-19-2008 06:54 PM
passing strings as arguments iago UNIX for Dummies Questions & Answers 1 08-22-2007 10:04 AM
Passing arguments to a script Kevin Pryke Shell Programming and Scripting 3 06-14-2002 09:06 AM
Passing arguments to an alias pmcg UNIX for Dummies Questions & Answers 1 10-23-2001 11:15 AM
passing arguments jpprial UNIX for Dummies Questions & Answers 4 04-03-2001 11:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2006
David.Vilmain David.Vilmain is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 1
Passing and using arguments in Scripts.

I am new to scripting in AIX / UNIX. I have a script that runs 4 other scripts and I want to be able to pass in a agrument that I can check before I run the next script to see if the previous script finished with no errors.

Can someone send me an example of this as I'm sure it's pretty easy to do....as long as you know how.

Thanks,

David.Vilmain
david.vilmain@wush.com
  #2 (permalink)  
Old 11-13-2006
Andrek Andrek is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 122
You can check the exit code after each of the four scripts you run, from insode your main script. If the first script exits with a status of 0 then continue with the second and then check it, etc....

eg

#Placing scripts to run in loop

for next in `echo "script1.sh script2.sh script3.sh script4.sh"`
do
/path/to/$next
done=$?
if [ $done -ne 0 ]
then
echo "FAILED - $next"
break
fi
done

If you want to pass arguments to a script you can place them on the command line and capture them inside the script using the standard $1, $2
eg

/path/to/script1.sh arg1 arg2

script1.sh would look like.....
#!/bin/sh
value1=$1
value2=$2
echo "$1 - $2"

Hope this is what your after
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0