Pass all received args to a (wrapped) child script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pass all received args to a (wrapped) child script
# 1  
Old 12-28-2009
Pass all received args to a (wrapped) child script

I'm writing a wrapper script (in bash) that wraps another (bash) script. When calling the wrapped script, I need to pass all the received arguments/options to it. Is there a built in variable that holds all the options? I wrote a little while loop (see below) which works. But I wanted to know if there was an easier way.

Thanks.

What I have now:
Code:
#!/bin/bash

#Code that sets some environment variables

ARGS=""
while [ "$1" != "" ]; do
    ARGS="${ARGS} $1"
    shift
done

. $(dirname ${0})/startup.sh ${ARGS}



---------- Post updated at 02:36 PM ---------- Previous update was at 01:45 PM ----------

I found that I can use $@ (I just had trouble finding a good Google search query)

Thanks.

For other people's future reference, see: Reference Cards
# 2  
Old 12-28-2009
Internal Variables

$*
All of the positional parameters, seen as a single word
Note "$*" must be quoted.
$@
Same as $*, but each parameter is a quoted string,
that is, the parameters are passed on intact, without interpretation or expansion.
This means, among other things, that each parameter in the argument list is seen as a separate word.
Note Of course, "$@" should be quoted.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dsh command - shell script - sys args?

Sorry, a noobie question....! I want to use a linux cluster to copy a list of files. I want to split the processing over 3 nodes so that each node gets (more or less) an equal share. My script (base.sh) to execute my copy script (copy.sh) looks something like: #!/bin/bash for NODE in 1 2... (4 Replies)
Discussion started by: pc2001
4 Replies

2. Shell Programming and Scripting

Store args passed in array but not the first 2 args

Store args passed in array but not the first 2 args. # bash declare -a arr=("$@") s=$(IFS=, eval 'echo "${arr}"') echo "$s" output: sh array.sh 1 2 3 4 5 6 1,2,3,4,5,6 Desired output: sh array.sh 1 2 3 4 5 6 3,4,5,6 (2 Replies)
Discussion started by: iaav
2 Replies

3. Shell Programming and Scripting

sh script for file received confirmation

I am new at scripting, (and this fourm- so hi guys!) and I was wondering is there something out there that I can use to do the following: I receive a file on an FTP server I would like a script to look at a specifc directory for a certain file and when it arrives it will send an email... (8 Replies)
Discussion started by: mamemlin
8 Replies

4. Linux

Run PHP script when new email received

I have been looking around for a solution to this, i have been developing for a wile though am very new to CGI, PHP and a lot of the web based tech. I have a web site hosted with a cPanel web host. I am looking to have a script(prefer PHP) to run everytime i get a new email to help@xxx.com.... (16 Replies)
Discussion started by: iKris
16 Replies

5. Programming

Pass parameter from a child make to a parent

Hello, I have the following problem: I have makefileproj and makefilemod in a build process for a complex project - from makefileproj I call the makefilemod. In makefilemod I generate a list containing objects eg,: "../../../25_Build/Results/Objects/FBL/Fls.o... (4 Replies)
Discussion started by: marina_lmv
4 Replies

6. Shell Programming and Scripting

problem with KSH script: command line args

Hi I am executing a KSH script by passing command line arguments example: Red Green Dark Red Blue when I am splitting the arguments by using " "(Space) as delimiter But the colour Dark Red is a single parameter. But it is getting splitted in between How to avoid this. Please help Also... (4 Replies)
Discussion started by: hemanth424
4 Replies

7. Programming

how to handle SQL exceptions to call script having args via java ?

Hi, i want to call shell script via java + in that shell script i m doing some sql operation by connecting to sqlplus . i want to return 0 if successful exeution of SQL operations else 1 ; is it possible ? #!/bin/sh Name=$1; export ORACLE_HOME $ORACLE_HOME/bin/sqlplus... (3 Replies)
Discussion started by: crackthehit007
3 Replies

8. Shell Programming and Scripting

C Shell Scripting - HELP! - checking total args in a script

Hi, I 'm trying to learn the scripting language and am trying to create a script to open a C Program, allow the user to edit it, and then run it. What I have works but only when you enter the name to be compiled and the c program, but what if you only entered the 1 argument (cprogram.c) ? but I 'm... (3 Replies)
Discussion started by: patel_ankz
3 Replies

9. Shell Programming and Scripting

what is the max length of args i can pass in shell?

i have a shell script which takes several args. what is the maximum length of string i can give as argument? (6 Replies)
Discussion started by: senthilk615
6 Replies

10. Programming

i want to pass the connect fd to child process,how can i do ti?

i write a function using to pass the socket connected fd to child process in the sco unix open server 5.0.5,but in fact i execute the program calling the fuction,system report send the fd error: Jul 12 12:15 send_fd.c: send_fd sendmsg to sd error how can i solve the problem ,please help me!!!... (6 Replies)
Discussion started by: hit
6 Replies
Login or Register to Ask a Question