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 SSH Command Parameters suchitasaner27 Shell Programming and Scripting 5 05-28-2008 06:38 AM
Building command line parameters of arbitrary length cmcnorgan Shell Programming and Scripting 2 11-20-2007 02:46 PM
Passing SSH Command Parameters PabloCruise77 SUN Solaris 2 03-05-2007 04:03 PM
How do you take in variables/parameters from the command line? avisram UNIX for Dummies Questions & Answers 1 07-21-2005 09:47 AM
passing parameters to sleep command nagaraju_svs UNIX for Dummies Questions & Answers 1 07-16-2003 09:17 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 03-05-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
passing command line parameters to functions - sh

All,

I have a sh script of the following tune:

function a () { #functionality.. }

function b () { #functionnlity.. }

function check () { # this function checks for env and if all fine call build }

function usage () { #sh usage details }

function build () { #calls either a or b or both }

if [ $# == 0 ] ; then
usage ;
else
check;
fi;
# end of script

I run the script as follows
sh build.sh a

Now I need to know how to pass the parameters i.e all to check, which in turn will pass it on to build.

uname -a is
Linux staci21 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux

Vino
  #2 (permalink)  
Old 03-05-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
try

Code:
check $*
  #3 (permalink)  
Old 03-05-2005
reborg's Avatar
reborg reborg is online now Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Quote:
Originally Posted by bhargav
try

Code:
check $*

or depending on the way you want to use the args
check $@

see:
man sh

for the explanation of both options
  #4 (permalink)  
Old 03-05-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
$@ and $* are absolutely identical in effect. You must surround them in double quotes to exploit the difference.
  #5 (permalink)  
Old 03-05-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Thanks to all.

Am using "$@"

Vino
  #6 (permalink)  
Old 03-05-2005
reborg's Avatar
reborg reborg is online now Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Quote:
Originally Posted by Perderabo
$@ and $* are absolutely identical in effect. You must surround them in double quotes to exploit the difference.
like I said read the man page...it explains that there.
Closed Thread

Bookmarks

Tags
linux

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 09:25 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