LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cannot run script file (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-run-script-file-4175500529/)

snowboy 04-04-2014 12:33 AM

cannot run script file
 
My OS is Debian Wheezy on a raspberry pi.
I am trying to run a script file which starts with the hashbang line #!/bin/sh and get the error message No such file/ folder. In debug mode (#!/bin/sh -x) i get the following message
/bin/dash: 0:illegal option -
I have tried everything I can think of with no success.

Any help or suggestions gratefully received

Highlander 04-04-2014 01:33 AM

FYI - Your Profile Distribution: has a typo in it.

Recommend you post your script using the # menu item in the Go Advanced editing function.
It should look like this...

Code:

The code goes here.

Madhu Desai 04-04-2014 01:57 AM

Probably /bin/sh is sim-linked to /bin/dash, or there is no sh shell and only dash shell is available. Dash is believed to be limited in functionality. So try /bin/bash hashbang and see what happens.

You can try this to find available shells in your system.
Code:

$ cat /etc/shells

chrism01 04-04-2014 04:31 AM

The above cmd is a good idea; I also recommend
Code:

ls -l /bin/*sh

snowboy 04-04-2014 07:44 PM

cannot run script file
 
Thanks to all for replies but no help. I have tried all available shells but always get the same message "Bad interpreter no such file or folder"
Snowboy

schneidz 04-04-2014 08:00 PM

I see you have windows in your profile.

ms adds cr-lf to the end of each line.

are you editing it in windows ?



also, try running this: cat -A script.ksh

snowboy 04-06-2014 04:09 AM

Hi everyone.I have at last fixed my problem.The file is a shell file and all that I could find said that the hashbang line must be line 1.
I moved that line to the first line after the INFO block and hey presto it works.

snowboy

chrism01 04-06-2014 04:55 AM

What 'INFO' block?

snowboy 04-06-2014 07:16 PM

script info block
 
LSB compliant files start with an INFO block. the first line is ### BEGIN INIT INFO then follows several lines of information about the script each beginning with a # the last line is ###END INIT INFO. That is where I had to put the shebang line.


All times are GMT -5. The time now is 01:27 PM.