The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bash: ./<scriptname>: No such file or directory Heidi.Ebbs SUN Solaris 10 06-29-2007 08:23 AM
OM not found aladdin UNIX for Dummies Questions & Answers 4 05-02-2007 02:42 AM
run script without ./scriptname NinjaXman UNIX for Dummies Questions & Answers 2 04-08-2007 12:39 PM
how can i check in csh if command found or not found ? umen Shell Programming and Scripting 2 03-03-2007 07:38 PM
echo Scriptname uXion Shell Programming and Scripting 1 06-05-2006 10:16 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
Unhappy /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 (permalink)  
Old 07-02-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
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 (permalink)  
Old 07-02-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
Quote:
Originally Posted by vgersh99 View Post
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 (permalink)  
Old 07-02-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by Browser_ice View Post
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 (permalink)  
Old 07-02-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
ok, understood
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0