Running a BATCH script from my korn script with multiparameters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running a BATCH script from my korn script with multiparameters
# 1  
Old 07-22-2009
Running a BATCH script from my korn script with multiparameters

I've this BATCH script to run from my korn script...

The command is

/usr/local/BATCH/runBatch.sh PARAM1 'PARAM2 -PARAM21 PARAM22'
(runBatch takes

parameter 1 = PARAM1
parameter 2 = 'PARAM2 -PARAM21 PARAM22'

)
If i run this command from command line it just runs fine...

But if i call it from my script ( using ksh )
(runbatch takes

parameter 1 = PARAM1
parameter 2 = 'PARAM2
parameter 3 = -PARAM21
parameter 4 = PARAM22'

)

Any idea guys?

what i found is kshell does not handle '' so well as in parameters....any thing on this would appreciate !!!
# 2  
Old 07-22-2009
I would not say that ksh does not handle params well, just because of a issue you faced. I have not experienced any issues in this regard.

You can try this.. Call runBatch.sh from your script, as follows:

Code:
/usr/local/BATCH/runBatch.sh $1 "$2"

Hope this works for you.
# 3  
Old 07-22-2009
Thanks for your reply ..

I've tried /usr/local/BATCH/runBatch.sh $1 "$2"

but still it does not work ...

Please make one script which handles parameters like i said ...

parameter 1 = PARAM1
parameter 2 = 'PARAM2 -PARAM21 PARAM22'

and write another ksh script and try kicking it off... i know it's not issue but trying to find out what's wrong ... Can not use any other shell than "ksh"

Appreciate your time ..
# 4  
Old 07-22-2009
prash184u, I don't see the problem. Here is what I have:

main.sh:
Code:
#!/bin/ksh

echo "PARM1=$1"
echo "PARM2=$2"
echo "Invoking runBatch.sh"

runBatch.sh $1 "$2"

runBatch.sh:

Code:
#!/bin/ksh

echo 
echo "In runBatch.sh"

echo "PARM1=$1"
echo "PARM2=$2"

I am invoking main.sh as follows:
Code:
main.sh  PARAM1 "PARAM2 -PARAM21 PARAM22"

And the output is:

PARM1=PARAM1
PARM2=PARAM2 -PARAM21 PARAM22
Invoking runBatch.sh

In runBatch.sh
PARM1=PARAM1
PARM2=PARAM2 -PARAM21 PARAM22

Aren't you seeing a similar output?
# 5  
Old 07-22-2009
You have not published your script, easier to give comments.

If you call any posix-sh, even bsh (sh, ksh, bash, ..) like:
Code:
./script  arg1  "arg2 is something- ex. $LOGNAME" 'arg3 is more'

And script is:
Code:
#!/bin/sh
#!/bin/ksh
#...
arg1="$1"
arg2="$2"
arg3="$3"
echo "arg1 = <$arg1>"
echo "arg2 = <$arg2>"
echo "arg3 = <$arg3>"

# now you can call some command
# put your variable insite " ". Why ? If your variable include argument delimeter, 
# then shell will use it. With " " you tell - parse only variable, $() and \, nothing else.
#
somecmd "$arg1"  "$arg2"  "$arg3"

# 6  
Old 07-22-2009
once change here...

Thanks g.pi,

Can you please quickly make one change here

main.sh
-------------------------
#!/bin/ksh

PARM1=PARAMETER1
PARM2="PARAMETER2 -PARAMETER21 PARAMETER22"
echo "Invoking runBatch.sh"

runBatch.sh $1 "$2"
--------------------------

and please call main.sh simply without any parameters ...
# 7  
Old 07-22-2009
Prash184u, that also works fine for me. Only correction that I had to make was to invoke runBatch.sh with $PARM1 and "$PARM2", instead of $1 and $2.

I hope kshji's example above, explains why you are seeing unexpected results.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

4. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

5. Shell Programming and Scripting

running a script in korn shell

I'm learning bash and have discovered that the shell can only work with integers and not decimals. I'd like to run my scripts in korn to account for this, but just now, when I tried to run my script, I got an error message that said 'no such file or directory,' even though when I'm in the shell... (3 Replies)
Discussion started by: Straitsfan
3 Replies

6. Shell Programming and Scripting

Change the Windows Batch script to UNIX shell script.

Hi, When I run the below script in UNIX it's throwing syntax errors. Actually it's a windows batch script. Could anyone change the below Windows Batch script to UNIX shell script... Script: REM :: File Name : Refresh_OTL.bat REM :: Parameters : %1 - Region REM :: : %2 - Cube Type REM ::... (5 Replies)
Discussion started by: tomailraj
5 Replies

7. UNIX for Dummies Questions & Answers

running script with korn shell

How would i instruct the current shell to run the current script using the korn shell? (1 Reply)
Discussion started by: JamieMurry
1 Replies

8. Shell Programming and Scripting

Running a Java Programm with a (korn)shell-script

hey everyone, For my studies i had to write a javaprogram which reads 2 integers from the keyboard and then using the basic operations(addition, division etc) with them. so far no problem. but now i gotta make a shell-script which: runs the program(compiled with javac) #!bin/ksh java... (1 Reply)
Discussion started by: simlmf
1 Replies

9. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

I am using awk in my .ksh script but when I am trying to run in windows its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like. thanx. #!/bin/ksh egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Discussion started by: 2.5lt V8
1 Replies

10. Shell Programming and Scripting

Korn Shell script not running

I am sorry, this is really trivial, yet I am not able to understand what the problem is! I am using korn shell and running this script #!/bin/ksh keep=3 while ; do echo $keep keep=$(($keep-1)) done I am getting this error: `keep=$' unexpected I am not able to understand it because ... (1 Reply)
Discussion started by: Asty
1 Replies
Login or Register to Ask a Question