Argumenting passed not echoing inside the script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Argumenting passed not echoing inside the script
# 1  
Old 08-21-2010
Argumenting passed not echoing inside the script

Hi
I have a program test.ksh

#! /bin/ksh
echo $1
echo $2

when i run this from command line like ksh test.ksh abc def
Its echoing the passed arguments correctly where as if i run form commadn line like test.ksh abc def its not echoing the parameters saying like test.ksh not found.But i ma running this in the command line on the directlry where the program residese . I gave echo $SHELL in command its resolving to /usr/bin/ksh also echo $PATH is resolvng to /usr/bin.

I just want to know why the option2 is not working

Your help is apprecaited.
# 2  
Old 08-21-2010
Your problem is nothing to do with the script itself, it's that the script is not being found in your PATH, most likely either because you forgot to mark the script as executable, or because your PATH does not include the current directory. Try this:

chmod +x test.ksh
./test.ksh abc def

and it ought to work.
# 3  
Old 08-21-2010
Hi Phil

Thanks for you reply,sorry i didn't mention in my provious thread.

Already it has given the permissions as 777 and also i tried earlier with ./test.ksh its working fine.

Since my programs will be called from the mainframe scheduler,in mainfrmae control card they can't give ./test.ksh they have given like test.ksh and also its very hard now to go and chnge in mainfrmaes.

I have pasted the the way i executed please see below.

PROD ca7dss@a1pvdb071 /dss/run > ls -ltr *test.ksh*
-rwxrwxrwx 1 ca7dss dss 66 Aug 21 20:49 test.ksh
PROD ca7dss@a1pvdb071 /dss/run > test.ksh abc def

No of argumetns passed is : 0
ksh[4]: test.ksh: not found.
PROD ca7dss@a1pvdb071 /dss/run > more test.ksh
#! /bin/ksh
echo $1
echo $2
echo "No of argumetns passed is : $#"

Kindly help me on this.
# 4  
Old 08-21-2010
Then you need to either put that script in a directory somewhere in the default system path, or find a way to have the caller specify the full path to it.
# 5  
Old 08-22-2010
Hi Phil

Thanks,

I just added the path where i am running this program in to $PATH.

Now its working fine.

Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

Shell script to find the sum of argument passed to the script

I want to make a script which takes the number of argument, add those argument and gives output to the user, but I am not getting through... Script that i am using is below : #!/bin/bash sum=0 for i in $@ do sum=$sum+$1 echo $sum shift done I am executing the script as... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

3. Shell Programming and Scripting

Three parameters passed from a script to other at different time

nothing (0 Replies)
Discussion started by: shikha84
0 Replies

4. UNIX for Advanced & Expert Users

Value of variable not getting passed in child script

Hi, I am facing a challenge in fixing an issue in my installation scripts.Here is a situation: There are 3 files which are invoked at a below given order: Installer.ksh----->Installer.xml(Ant script)------->common.ksh I am outputting a message from common.ksh at a terminal, after that trying to... (3 Replies)
Discussion started by: baig_1988
3 Replies

5. Shell Programming and Scripting

Getting the file name passed to a shell script

Hi all I want to use the filename passed into a shell script within the shell it self. The file will be passed as shown below ./myScript < myFile.file i tried $1 but i think since myFile is not passed as a command line arg its not saving the file name in $1 any help is appreciated. (5 Replies)
Discussion started by: sridanu
5 Replies

6. Shell Programming and Scripting

flags passed to an awk script

I have an awk script script.awk for example and want to pass a flag (let's call it "neat") so that the data is put into nice columns. For example like this awk -v neat -f script.awk fin > fout Then check inside the program if the use has put neat, if yes I output the lines in nice columns,... (1 Reply)
Discussion started by: kristinu
1 Replies

7. Homework & Coursework Questions

Loosing formatting when echoing an awk script

1. The problem statement, all variables and given/known data: When I echo out the output of my awk script I loose the formatting that I set in my awk script (it should be in a table format). 2. Relevant commands, code, scripts, algorithms: 3. The attempts at a solution (include all... (2 Replies)
Discussion started by: ROFL
2 Replies

8. Shell Programming and Scripting

Problem with script not able to take parameters passed to it

debug output: (3 Replies)
Discussion started by: dsravan
3 Replies

9. Shell Programming and Scripting

How to get files names passed to a script

I need to get files names passed to a script. Here number of files passed may vary like MyScript.ksh file1 file2 file3..... so on I am writting script somthing like this set -A Files while (i<=$#) do File=$i let i=i+1 done Is this correct way doing this. Is there any other way.... (5 Replies)
Discussion started by: unishiva
5 Replies

10. Shell Programming and Scripting

Problem with script not able to take parameters passed to it

when I pass any 2 parameters it always says: Number of parameters passed: 1 and the job_name as x Can some body help? (7 Replies)
Discussion started by: dsravan
7 Replies
Login or Register to Ask a Question