October 24th, 2004, 01:06 AM
Can not run script file. Command not found.
For some reason, I can not run ANY script file on my unix account. I know the scripts are correct because my friend can run them. I have tried adding in the script's path to my PATH variable but still I get the same error everytime I try to run any script: Command not found. Any ideas??
October 24th, 2004, 03:49 AM
Do you have the correct file permissions for the script? If you wrote the script and saved it in your home directory or another directory that you have write access to, than you should just be able to chmod 700 the script file - giving the owner of the file and only the owner of the file read, write, and execution permissions. If the script's owner is someone other than you than you might have to change the permissions such that you have execution permissions for the script.
Originally Posted by ninjamyst
October 24th, 2004, 05:46 AM
(or somethings like that) is a permission issue
command not found
is a PATH issue
October 24th, 2004, 12:38 PM
When I issue the command "which scriptname", it can not find the script so I know it has to do with my PATH environment. However, I am running the script with ./scriptname which should tell the shell to find the script in the current directory...so what's wrong????
October 24th, 2004, 02:01 PM
That's true, sorry, my mistake. Though it is wierd since you are executing it via ./script because when I don't then I do get the command not found error.
Originally Posted by guggach
user@localhost ~/> blah.bash
bash: blah.bash: command not found
Although I did some testing on my Sun account:
pegasus% ls -al *.bash
-rwx------ 1 user 25 Oct 24 03:47 test.bash
pegasus% echo $SHELL
./test: Command not found
Hence you are executing the file with it's extension, neh? Just asking because in the above example when I failed to specify the extension I recieved the error "Command not found"
October 25th, 2004, 02:11 AM
If still not solved (if you have check for proper file permission and PATH) then can you provide the ls -l and echo $PATH and your username outputs to me.
November 3rd, 2004, 05:42 AM
how should the shell be able to expand names ?
you are using csh (i hope: on cmd-line only)
if in your .login (you also can do it in .cshrc) is: set filec
and you type: ./xxx<ESCAPE>
csh (bash copied it, ksh uses: <escape><backslash>) will expand it
when UNIQUE, else complain, in this case enter ./xxx<CTRL-D>
to get a list of all ./xxx*
November 3rd, 2004, 11:39 AM
How about adding the current directory to the PATH?
The following command will do this:
April 8th, 2011, 11:52 AM
Files transfered from Win to Unix (FTP)?
If your script files were not recognized by your FTP client - and they transferred onto your Unix box as binary - this is the exact behavior you will find. Go back and transfer your script again - but be sure to use FTP ASCII xfer mode. I hope it is no problem to post to an old thread.
April 10th, 2011, 07:54 AM
Who mentioned ftp and that was 7 years ago!
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
June 14th, 2012, 05:35 AM
Thank you so much rstarg!
I had the same issue today and could fix it after reading your answer.
June 23rd, 2012, 09:52 PM
"Command not found" ... is a misleading error message.
After having a similar problem and trying
chmod 700 filename.sh
Seems the issue was the shell could not understand the file's format, likely because Unix and DOS files have different line terminations. By the way I created my file on a PC using an editor then I used FileZilla to drag and drop to transfer. My guess is if I had created the file within my Unix account I would have never encountered this error.
As far as FTP transfer of files with different modes, I am curious to see how a file transferred in ASCII mode differs from a non ASCII mode transfer. My guess is it changes the line termination characters for each row from CR LF (carriage return line feed) into CR (I think). Whereas a Binary transfer likely does not change row data (for example if the file was a picture).