Issue in passing a parameter value from one script to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue in passing a parameter value from one script to another
# 1  
Old 07-21-2010
Data Issue in passing a parameter value from one script to another

Hi Experts,

I am passing current month & day (i.e. 'Jul 21') from script aaa.ksh to zzz.ksh. The value 'Mon DD' is being used in zzz.ksh.

Problem: If I pass 'Mon DD' value manually to zzz.ksh i.e.

Code:
/test/zzz.ksh 'Jul 21'

it works fine. However, if I pass value from aaa.ksh, it does not.


In aaa.ksh, I am passing value following way:
Code:
l_day=$(date '+%b %d')

$JOBSDIR/zzz.ksh $l_day


In zzz.ksh, the value is being used following way:
Code:
LsFiles | grep "$@" | awk '{print $NF}' > list_of_files.txt

Note: LsFiles is a function.

If I call zzz.ksh from aaa.ksh it says:
Code:
grep: 21: No such file or directory

I put 'echo $@' to find the value and both way it returns Jun 21

Thanks in advance
Dip

Last edited by Scott; 07-21-2010 at 03:41 PM.. Reason: Added code tags
# 2  
Old 07-21-2010
Hi.

You quoted it when you calling it directly, but not from your script?

Code:
$JOBSDIR/zzz.ksh $l_day

(using double quotes...)
Code:
$JOBSDIR/zzz.ksh "$l_day"

This User Gave Thanks to Scott For This Post:
# 3  
Old 07-21-2010
Thanks scott. It works now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

2. Shell Programming and Scripting

Passing parameter filled variable to a script.

Say I have something like this to try and build a parameter string: OPT1="This is my Option"; OPT2="/folder/file"; PARMS="-u me -J \"$OPT1\" -g \"$OPT2\""; ./script.ksh -n 1 $PARMS; ./script.ksh -n 2 $PARMS; ./script.ksh -n 3 $PARMS; ./script.ksh -n 4 $PARMS; But this doesn't work. ... (2 Replies)
Discussion started by: Devyn
2 Replies

3. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

4. Shell Programming and Scripting

Passing Parameter containing space in between to Shell Script

Hi, I have one shell script which use two parameter however one of its parameter have space in between. eg. a.sh 20110114 b c d here b c d is one parameter I used 'b c d' but its not giving correct result. Also i tried b\c\d but this one also didnt work. Any help would be... (5 Replies)
Discussion started by: diehard
5 Replies

5. AIX

Passing a parameter to a shell script?

I would like to run a compress script on files in certain directories. My compress_script.sh is just basically compress file* In order for me to use this I have to copy it into each directory and run it. How can I state the directory on the command line with the compress script so it... (2 Replies)
Discussion started by: NycUnxer
2 Replies

6. UNIX for Dummies Questions & Answers

ISSUE on SFTP fucntion ,parameter passing!

Hi Everyone!! Hey i created a SFTP function to FTP the file from unix to Linux. I need to FTP the 48 files from unix to linux. IP=$1 Userid=$2 Prikeypath=$3 SrcPath=$4 DstPath=$5 Files=$6 BATCHFILE=sftp.batch.$$ LOGFILE=sftp.log.$$ #Compose batch file & pass as argument to the... (1 Reply)
Discussion started by: bobprabhu
1 Replies

7. Shell Programming and Scripting

Passing parameter from one file to shell script

Hi All, I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date. everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file. ... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

8. Shell Programming and Scripting

Passing Filename as a Parameter to Another script

Hi, I have a requirement to write a script file(script1.sh) to read the file from the folder say /usr1/profiles/active and pass the file name as a parameter to another script file say (script2.sh) which would subsitute this parameter. The script2.sh will have a line like the one below ... (1 Reply)
Discussion started by: ravisg
1 Replies

9. Shell Programming and Scripting

Passing a parameter while calling a script

Hello everyone I was asked to pass a parameter in the calling of a script. IŽll have two parameters London and Birmingham and IŽll need to pass this because each of these will have a specific script however with the same name. /home/script/loaddata.ksh Lond /home/script/loaddata.ksh Birm... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies

10. Shell Programming and Scripting

Passing Date as parameter with sh script

Hi I need to pass a date argument with my shell script. Can any one send me code for the same. eg For 15th Aug 2006. Iwant to pass parameter like this ./startenv.sh 08/15/2006. Everyday date argument must change. Will the below code work ? ./startenv.sh date '+%m/%d/%y' THanks... (1 Reply)
Discussion started by: pankajkrmishra
1 Replies
Login or Register to Ask a Question