#!/usr/bin/ksh Command Interpreter in a sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting #!/usr/bin/ksh Command Interpreter in a sh script
# 1  
Old 07-08-2005
#!/usr/bin/ksh Command Interpreter in a sh script

Hi,

I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here is the script:

#!/usr/bin/ksh



#--create test file to read

#

echo "1" > test_file

echo "2" >> test_file

echo "3" >> test_file



#--WHILE READ should populate variables when shell contains #!/usr/bin/ksh

#

record_cnt=0

initial="OUTSIDE"



while read record ##--placed into $record

do

record_cnt=`expr $record_cnt + 1`

initial="INSIDE"

echo "Records Read=$record_cnt”

done < test_file ##--input file to be read



echo " "

echo "Records Read=$record_cnt"

echo "Initial=$initial"



exit 0
# 2  
Old 07-08-2005
sh is ignoring it because it's a comment. Feeding a ksh script into sh like that is not the correct thing to do. But if you do it, sh will attempt to run it. Read our faq article on this subject.
# 3  
Old 07-08-2005
Thanks, Perderabo. Can you post the link for the FAQ?
# 4  
Old 07-08-2005
Here you go. But the FAQ is just a click away, why not look through the entire FAQ and see what other interesting things you can pick up?
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

-bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory

I keep getting this error and I am not sure why. -bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory First I run my makefile and this works fine: goodmain: main.o gcc -o goodmain main.o main.o: main.c gcc -c main.c Then I want to limit my output so I... (11 Replies)
Discussion started by: cokedude
11 Replies

2. Shell Programming and Scripting

/usr/bin/ksh -E

I saw one script using the first line as below /usr/bin/ksh -E I have used -x for debug but couldn't find what is this -E option for ? Pls let me know what is this -E used for Thanks RL (1 Reply)
Discussion started by: reldb
1 Replies

3. AIX

aix:ksh: /usr/bin/rm: 0403-027 The parameter list is too long.

Hi, I am getting the below error message When i am trying to delete the files from the directory.Could you please guide me? rm *.aud ksh: /usr/bin/rm: 0403-027 The parameter list is too long. and find /oracle/admin/testP/adump/*.aud -mtime +5 -exec rm {} \; ksh: /usr/bin/find:... (3 Replies)
Discussion started by: nokiae63
3 Replies

4. Shell Programming and Scripting

!/usr/bin/ksh error

Usually we use !/usr/bin/ksh at the start of the script.But if I am having this stuff in the scripts and calling one script from other its not working.What may be the reason behind it ? xyz.ksh #!/usr/bin/ksh echo "Hi" abc.ksh #!/usr/bin/ksh echo "I am fine" ksh xyz.ksh Its... (4 Replies)
Discussion started by: dr46014
4 Replies

5. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

6. Shell Programming and Scripting

Problem with /usr/bin/cd command

Hi , My shell script doesnt function properly while executing. My shell script has the below mentioned code in it. #!/bin/sh CD="/usr/bin/cd" .. .. $CD / .. .. main intention behind giving the $CD / is to replace the cd command with /usr/bin/cd at the time of program execution. ... (5 Replies)
Discussion started by: raghu.amilineni
5 Replies

7. Tips and Tutorials

The Whole Story on #! /usr/bin/ksh

Introduction Originally, we only had one shell on unix. When ran a command, the shell would attempt to invoke one of the exec() system calls on it. It the command was an executable, the exec would succeed and the command would run. If the exec() failed, the shell would not give up, instead it... (3 Replies)
Discussion started by: Perderabo
3 Replies

8. UNIX for Dummies Questions & Answers

ksh: /usr/bin/ls: arg list too long

I am using IBM AIX unix version 4.3.3.0. In a directory there are many files with different patterns. When I am trying to execute the command, ls -l with the file pattern, which have fewer files it gives the desired result. However when I am trying to execute the same command for file pattern,... (2 Replies)
Discussion started by: jitindrabappa
2 Replies
Login or Register to Ask a Question