Pass script with parameter in korn shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pass script with parameter in korn shell script
# 1  
Old 08-13-2015
Pass script with parameter in korn shell script

I have written a script which will take input parameter as another script.
However, if the script passed as input parameter has parameters then this script doesn't work.

I have a script b.ksh which has 1 and 2 as parameters
I have a script c.ksh which has 3,4 and 5 as parameters

vi a.ksh
Code:
USAGE="<SCRIPT_NAME>"
while [ 1 ]; do
nohup ${SCRIPT_NAME}
done

I call the scripts like this
Code:
ksh -x a.ksh b.ksh 1 2
ksh -x a.ksh c.ksh 3 4 5

The above doesn't work though. Please help

Last edited by Don Cragun; 08-13-2015 at 09:18 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 08-13-2015
Quote:
Originally Posted by Vee
I have written a script which will take input parameter as another script.
However, if the script passed as input parameter has parameters then this script doesn't work.

I have a script b.ksh which has 1 and 2 as parameters
I have a script c.ksh which has 3,4 and 5 as parameters

vi a.ksh
Code:
USAGE="<SCRIPT_NAME>"
while [ 1 ]; do
nohup ${SCRIPT_NAME}
done

I call the scripts like this
Code:
ksh -x a.ksh b.ksh 1 2
ksh -x a.ksh c.ksh 3 4 5

The above doesn't work though. Please help
I'm not sure where to start:
  1. You assign a seemingly meaningless string to the variable USAGE, but you never use that variable.
  2. You use the variable SCRIPT_NAME, but you never assign it a value.
  3. You have a while loop to repeatedly nohup nothing.
  4. None of the code in your script uses any arguments passed to your script.
If you want to run b.ksh with the arguments 1 and 2, why don't you just invoke:
Code:
b.ksh 1 2

? Why do you need a.ksh?

Please explain more clearly what you are trying to do with this script!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (3 Replies)
Discussion started by: Debalina Roy
3 Replies

2. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (2 Replies)
Discussion started by: Debalina Roy
2 Replies

3. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script 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 | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

4. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

5. Shell Programming and Scripting

Pass parameter to nawk from shell script

I need to parse log files using nawk, but I'm not able to pass script input argument (date) to nawk, for example: ------------ #!/bin/ksh read date nawk -F, '{if($1==date) print $4" "$5}' ------------- Is there a way to pass an argument to nawk from shell script. Many thanks... (8 Replies)
Discussion started by: samer.odeh
8 Replies

6. Shell Programming and Scripting

How to pass parameter to User defined function in shell script?

Hello, Can anyone guide me tin passing parameters into user defined function of shell script (KSH). Here is my code, InsertRecord() { DB_TBL=$(sqlplus $USERID/$PASSWORD@$DATABASE << EOF set head off set feed off set serveroutput on INSERT INTO TBL1 ( OLD_VAL, NEW_VAL, ... (7 Replies)
Discussion started by: Poonamol
7 Replies

7. Shell Programming and Scripting

What is the maximum number of parameter we can pass to a shell script function?

what is the maximum number of parameter we can pass to a shell script function (8 Replies)
Discussion started by: alokjyotibal
8 Replies

8. Shell Programming and Scripting

How to pass a variable as a parameter to DB2 database from shell script

I need to pass a variable as a parameter from shell script into a DB2 database. var=bhuk_1123_Q_11/22/09 select * from tbl1 where serial_id='$var'; I have tried executing it using db2 -tvf scriptname Somebody please help me out with this. It is throwing an error. Please tell me how... (2 Replies)
Discussion started by: ss3944
2 Replies

9. Shell Programming and Scripting

How to pass parameter from sqlplus(procedure completed) to your shell script

if then # mail -s "Import failed file does not exist" sanjay.jaiswal@xyz.com echo "FILE does not exist" exit 1 fi echo "FILE EXIST" size=-1 set $(du /export/home/oracle/nas/scott21.dmp.gz) while do echo "Inside the loop" size=$1 set $(du... (1 Reply)
Discussion started by: sanora600
1 Replies

10. Shell Programming and Scripting

How to pass a parameter from one Shell-script to another Shell-script

Dear Friends, Please help me. How can I pass a parameter from one Shell-script to another Shell-script. Example: FirstScript.sh ------------- ./SecondScript.sh 'paramater' And SecondScript.sh --------------- doing something with passed parameter from FirstScript.sh Please... (2 Replies)
Discussion started by: subodhbansal
2 Replies
Login or Register to Ask a Question