LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-04-2014, 12:33 AM   #1
snowboy
LQ Newbie
 
Registered: Jan 2014
Location: Australia
Distribution: Debian Wheezy on Raspberrypi
Posts: 4

Rep: Reputation: Disabled
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

Last edited by snowboy; 04-04-2014 at 12:36 AM.
 
Old 04-04-2014, 01:33 AM   #2
Highlander
Member
 
Registered: Apr 2014
Location: Glenfinnan, Scotland
Distribution: Cinnamon
Posts: 76

Rep: Reputation: 2
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.

Last edited by Highlander; 04-04-2014 at 01:39 AM.
 
Old 04-04-2014, 01:57 AM   #3
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
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

Last edited by mddnix; 04-04-2014 at 02:01 AM.
 
Old 04-04-2014, 04:31 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
The above cmd is a good idea; I also recommend
Code:
 ls -l /bin/*sh
 
Old 04-04-2014, 07:44 PM   #5
snowboy
LQ Newbie
 
Registered: Jan 2014
Location: Australia
Distribution: Debian Wheezy on Raspberrypi
Posts: 4

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-04-2014, 08:00 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,147

Rep: Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887
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

Last edited by schneidz; 04-04-2014 at 08:06 PM.
 
Old 04-06-2014, 04:09 AM   #7
snowboy
LQ Newbie
 
Registered: Jan 2014
Location: Australia
Distribution: Debian Wheezy on Raspberrypi
Posts: 4

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-06-2014, 04:55 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
What 'INFO' block?
 
Old 04-06-2014, 07:16 PM   #9
snowboy
LQ Newbie
 
Registered: Jan 2014
Location: Australia
Distribution: Debian Wheezy on Raspberrypi
Posts: 4

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] parse file and use output to run a script johnthrax Programming 4 06-13-2013 09:40 AM
[SOLVED] Script file fails when run from crontab. karelvdm Linux - Newbie 3 12-29-2010 03:59 AM
how to run .pl script file asifbasha Fedora 2 04-11-2009 09:16 AM
Automatically run script on file? paddyjoy Linux - Software 3 10-03-2006 04:29 PM
how to run a script on subfolder file in a folder saggi_sam Linux - Newbie 5 07-13-2005 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration