Passing parameters with spaces between scripts

Tags
parameter passing, passing, script, scripts, shell scripts, space, spaces

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 1 Week Ago
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 1 Week Ago
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 to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with passing parameters from a file karthik adiga Shell Programming and Scripting 4 05-07-2015 06:18 AM
Passing Parameters to Crontab MaheshChaudhari Shell Programming and Scripting 7 02-11-2015 05:59 PM
Passing 2+ parameters to one command newbie2010 Shell Programming and Scripting 3 07-08-2013 01:54 PM
passing parameters with spaces sandy162 Shell Programming and Scripting 11 08-29-2012 12:26 PM
passing parameters to the script knip Shell Programming and Scripting 4 05-06-2012 04:43 PM
Passing the parameters through a file gaur.deepti UNIX for Dummies Questions & Answers 6 04-14-2011 12:18 PM
Passing the parameters using a function shruthidwh Shell Programming and Scripting 3 04-12-2011 11:00 PM
Automate the passing of parameters stunnerz_84 Shell Programming and Scripting 6 02-21-2011 05:53 PM
passing parameters using awk akil Shell Programming and Scripting 4 07-24-2009 01:53 AM
[/bin/sh] passing parameters with quotes between 2 scripts velo_love Shell Programming and Scripting 0 07-25-2008 05:13 AM
Passing SSH Command Parameters suchitasaner27 Shell Programming and Scripting 5 05-28-2008 07:38 AM
passing more than 9 parameters dnat Shell Programming and Scripting 2 03-03-2008 12:30 PM
problem in passing parameters with spaces njraman Shell Programming and Scripting 2 07-26-2007 05:37 AM
Passing parameters through a file chawlaaman Shell Programming and Scripting 3 07-17-2006 03:56 PM
Passing parameters in script eliguy UNIX for Dummies Questions & Answers 1 08-01-2001 02:13 PM
All times are GMT -4. The time now is 06:36 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.