Passing parameters with spaces between scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing parameters with spaces between scripts
# 1  
Old 12-07-2018
Passing parameters with spaces between scripts

I have 2 scripts. test.sh, which calls submit2.sh. One of the parameters contains space and is quoted.


Code:
[test.sh]
((((./submit2.sh Group_1_2_AMS_DAILY_CORE_GRP03 AMS AMS_D 'DAILY REPORT PROCEDURES'; echo $?>&3) | tee 1.log >&4)3>&1) | (read xs; exit $xs)) 4>&1


[submit2.sh]
echo parm 1 = $1
 echo parm 2 = $2
 echo parm 3 = $3
 echo parm 4 = $4
 echo parm 5 = $5
 echo output ....
 exit 42


I ran:
$ bash test.sh ; echo $?


I would expect:
parm 1 = Group_1_2_AMS_DAILY_CORE_GRP03
 parm 2 = AMS
 parm 3 = AMS_D
 parm 4 = DAILY REPORT PROCEDURES
 parm 5 =
 output ....
 42


I works fine in Bash shell, but not in ksh. Ksh returns
parm 1 = Group_1_2_AMS_DAILY_CORE_GRP03
parm 2 = AMS
parm 3 = AMS_D
parm 4 = DAILY
parm 5 = REPORT
output ....
42

The 4th parameter is split by word, not by the quoted text. Why is this happening? Any settiings on the Unix level?
# 2  
Old 12-07-2018
It works fine in both bash and ksh on my system, but -- I suspect test.sh is being run in neither bash nor ksh. You've left that to system defaults and hoped. Which means on some systems you might get anything from a 1977-era mouldy old Bourne, to C shell.

Add #!/bin/sh as the first line to both scripts and try again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with passing parameters from a file

Hello Everyone, I have developed a shell script which takes schema id and password as parameter to login into database using sqlplus,runs a query and mails the result. My requirement is that, I dont want to pass userid and password as parameters.Instead,I want to pass say Environment... (4 Replies)
Discussion started by: karthik adiga
4 Replies

2. Shell Programming and Scripting

Passing Parameters to Crontab

Hello Experts, I have a requirement to pass some parameters to Linux cron tab. For ex: My default cron entry looks like this as below: ------------------------------- 55 10 * * --... (7 Replies)
Discussion started by: MaheshChaudhari
7 Replies

3. Shell Programming and Scripting

Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this: for i in `cat /tmp/listofpolicies`; do for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g'); do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done The problem is that the... (3 Replies)
Discussion started by: newbie2010
3 Replies

4. Shell Programming and Scripting

passing parameters with spaces

we are using following script to execute stored procedue. The problem is run_pmcmd.ksh script is using $* parameter which is not taking in account 'Men Shirt' parameter which includes spaces. 1. Step 1 run_pmcmd.ksh CONVERT_TEST script for run_pmcmd.ksh /u01/$(whoami)/run_pmcmd.ksh... (11 Replies)
Discussion started by: sandy162
11 Replies

5. UNIX for Dummies Questions & Answers

Passing the parameters through a file

Hi All, I have written a shell script and the script is working fine, I am passing my MIT_ID(NUMBER VALUE) to the shell script from the command prompt and my script is executing as expected. Now I have to pass all the MIT_ID's from a .txt file to the shell script,as I am automating this I... (6 Replies)
Discussion started by: gaur.deepti
6 Replies

6. Shell Programming and Scripting

Passing the parameters using a function

Hi All, I am new to shell scripting required some help in passing the parameter value to the shell script. I am writing a shell script, in the script I have created two functions as below. first function get_trend_ids () { Here I am connecting to the database and getting all the... (3 Replies)
Discussion started by: shruthidwh
3 Replies

7. Shell Programming and Scripting

passing parameters using awk

Hi, The below script is working fine awk1.sh ======= awk BEGIN { FS="|" } FNR==NR { f1=$2; next } $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} awk -f awk1.sh a.txt b.txt--Its working fine . When passing parameters its not working .Any help it should be appereciated. ... (4 Replies)
Discussion started by: akil
4 Replies

8. Shell Programming and Scripting

[/bin/sh] passing parameters with quotes between 2 scripts

Hi, I have a first shell script (/bin/sh) that receives some paremeters. This is only an example (there are more parameters in fact and this one is among them): -header "This is a test" This script calls a secund shell script (/bin/sh) with the same parameters. But, quotes disappear as I would... (0 Replies)
Discussion started by: velo_love
0 Replies

9. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies

10. Shell Programming and Scripting

problem in passing parameters with spaces

hi im passing 4 parameters to a file....like /userr/script/go.sql $1 $2 $3 $4 and i get them in the other script and make and insert into the tabke insert into xy values('&1','&2','&3','&4'); what is the problem is tht when any one paramter has a space in them like "airtel... (2 Replies)
Discussion started by: njraman
2 Replies
Login or Register to Ask a Question