/bin/ksh: scriptname: not found. ???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting /bin/ksh: scriptname: not found. ???
# 1  
Old 07-02-2009
Data /bin/ksh: scriptname: not found. ???

I have started to write Korn scripts on the client's AIX 4.2 servers and there is this small problem that puzzles me.

I code all my scripts the same way:
- first line contains :
#!/bin/ksh

- I do this console command on every scripts:
chmod +x scriptname

But still, on some occasions, when running a script (ex: called scriptname.sh), I get an error that I do not understand:
/bin/ksh: scriptname.sh: not found.

It does not always happen but when it happens, its when I am trying to run a new script for the first time. Once it starts to happen, the only way to run that script is to :
ksh scriptname.sh

If a script never had this from the start, it will never happen to it. When logging in with my user-id, the first thing I do is sudo su -


Why is this happening ?
Am I forgetting to do something ?
I do not recall if it is happening on specific servers or not.
# 2  
Old 07-02-2009
Most likely the directory where your 'scriptname.sh' resides is not in $PATH. Or you don't have '.' in your $PATH.
Try either:
Code:
./scriptname.sh
OR
/absolutePath/scriptname.sh

# 3  
Old 07-02-2009
Quote:
Originally Posted by vgersh99
Most likely the directory where your 'scriptname.sh' resides is not in $PATH. Or you don't have '.' in your $PATH.
Try either:
Code:
./scriptname.sh
OR
/absolutePath/scriptname.sh

But can't I run any scripts from anywhere as long as I am in the same folder of it ?

I mean, if it is coded to be recognized by KSH and is executable, then if I am in the same folder, I should be able to run it no matter what's in the PATH ?

added comments ...
I checked on that server and I have ksh in both /usr/bin and /bin . But the PATH does not contain /bin in it. It does have /usr/bin

Last edited by Browser_ice; 07-02-2009 at 10:18 AM..
# 4  
Old 07-02-2009
Quote:
Originally Posted by Browser_ice
But can't I run any scripts from anywhere as long as I am in the same folder of it ?
This is a confusing question - I'm not sure what you mean.
I'm not aware of any 'folders' - maybe directories?
Quote:
Originally Posted by Browser_ice
I mean, if it is coded to be recognized by KSH and is executable, then if I am in the same folder, I should be able to run it no matter what's in the PATH ?
Nope, $PATH defines your.... well, sequence of directories to search for a named executable. If the current directory (.) is not in the list of paths, it will not be searched.
# 5  
Old 07-02-2009
ok, understood
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Should I run scripts like sh /absolute_path/to/scriptname.sh or just /absolute_path/to/scriptname.sh

Shell : Linux Bash OS version : RHEL 6.X, Oracle Linux 6.X Question1. To execute shell scripts, sometimes I see Linux admins placing sh command before shell scripts like below sh /home/appadmin/sync_pending_orders.shBut, I execute shell scripts like below ie. Just the absolute path ... (4 Replies)
Discussion started by: John K
4 Replies

2. Open Source

/usr/bin/sh xlc not found

Hi Everyone, We are trying to compile Kerberos library using xlc and we get an error that xlc is not found in the system. We tried using gcc as well but it also fails with the same error. We could not find the compiler in the software media we received from IBM. Any inputs on how... (2 Replies)
Discussion started by: madhav.kunapa
2 Replies

3. Shell Programming and Scripting

/bin/sh: : not found error

Hello, When i run the shell script in Solaris, i am getting the below error. /bin/sh: Test.sh: not found I have tried including "#!/bin/bash" , did not work, tried with #!/bin/ksh , did not work, tried without the above include in the script, but still did not work. Please help me to... (5 Replies)
Discussion started by: balareddy
5 Replies

4. Shell Programming and Scripting

/bin/bash: Event not found.

Hi I'm new to scripting - please help me... I'm trying to run a script written by a friend: #!/bin/bash for aStat in .... do .... done when coping the script to the terminal I get: /bin/bash: Event not found. for: Command not found. (7 Replies)
Discussion started by: atira
7 Replies

5. AIX

/usr/local/bin/cvs: Not found

I can able to access /usr/local/bin/cvs in the terminal (AIX 6.1 Box). but i am getting the "/usr/local/bin/cvs: Not found " when i call it from the script. please some one assist me what maybe problem (6 Replies)
Discussion started by: hifirockz
6 Replies

6. Debian

exec: 193: ./firefox-bin not found

Hi, all. When I run iceweasel as normal user in squeeze, I got forrowing message. exec: 193: ./firefox-bin: not found I think this is readlink problem, because ... #cat /usr/bin/iceweasel line 40........... MOZ_APP_LAUNCHER=$(which $0) MOZ_DIST_BIN= $(dirname $(readlink -f... (3 Replies)
Discussion started by: miru
3 Replies

7. 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

8. Shell Programming and Scripting

/bin/sh and /bin/ksh problem

we have a shell script that we are using in KSH if ]; then _IFS=$IFS IFS=: and it's failing on /bin/sh . Is there a simple way to modify it to work on both . ( not with awk) Thanks in adv (3 Replies)
Discussion started by: talashil
3 Replies

9. Shell Programming and Scripting

#!/bin/sh and #!/bin/ksh

Hi All, I have a shell (#!/bin/sh) with below piece of code: if ! then echo Staging table ABC_INT_TAB is not present in the schema >> $OUTPUT fi Shell is throwning below error and continue to work even after this error... (3 Replies)
Discussion started by: bhush782003
3 Replies

10. Shell Programming and Scripting

#!/bin/ksh

Hi. What does this command do in the shell script? #!/bin/ksh I have some scripts which do not run if this line is removed. First I thought it is comment but I think it sets up korn as shell. Sanjay (2 Replies)
Discussion started by: sanjay_g
2 Replies
Login or Register to Ask a Question