#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    31
    Rep Power
    11

    Can not run script file. Command not found.


    Hi,

    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??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Central Florida, U.S.A.
    Posts
    77
    Rep Power
    10
    Originally Posted by ninjamyst
    Hi,

    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??
    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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Middle Europa
    Posts
    1,200
    Rep Power
    14
    NO ShizukaWashi
    the message:
    permission denied
    (or somethings like that) is a permission issue
    but
    command not found
    is a PATH issue
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    31
    Rep Power
    11
    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????
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Central Florida, U.S.A.
    Posts
    77
    Rep Power
    10
    Originally Posted by guggach
    NO ShizukaWashi
    the message:
    permission denied
    (or somethings like that) is a permission issue
    but
    command not found
    is a PATH issue
    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.

    user@localhost ~/> blah.bash
    bash: blah.bash: command not found
    user@localhost ~/>./blah.bash
    Hello
    user@localhost ~/>

    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
    /bin/csh
    pegasus% ./test
    ./test: Command not found
    pegasus% ./test.bash
    Hello
    pegasus%
    ====================================

    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"
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    4
    Rep Power
    0
    Hi,
    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.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Middle Europa
    Posts
    1,200
    Rep Power
    14
    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*
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    60
    Rep Power
    10
    How about adding the current directory to the PATH?

    The following command will do this:
    PATH=$PATH:.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    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.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,449
    Rep Power
    1751
    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
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0
    Thank you so much rstarg!

    I had the same issue today and could fix it after reading your answer.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0
    "Command not found" ... is a misleading error message.

    After having a similar problem and trying
    filename.sh
    ./filename.sh
    chmod 700 filename.sh

    This worked...
    dos2unix filename.sh
    ./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).

IMN logo majestic logo threadwatch logo seochat tools logo