The place to post if you need help or advice
Moderators: ChrThor, LXF moderators
I have a shell script that runs automatically following a 'hotplug' event.
Leaving the hotplug to do its thing results in a 'bad interpereter' error. If I try to run the script just using the path ie
it gives me the same error.
However using the bash command then it works ok. This makes me assume that the error is due to the system not understanding the script is a bash script
The thing is that there are other scripts in that directory, doing the same job but for differnt equipment, that do not need the bash command to run.
What do I need to do to get the script to run impliclty as a bash script rather than being explicit with the bash statement.
Any help would be great
Itnsounds like you are missing the shebang line from the start of the script, although that can't be more than a guess because you have given no information about the script itself. The script should start with
- Code: Select all
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
- Site admin
- Posts: 8615
- Joined: Mon Apr 04, 2005 11:52 am
- Location: Warrington, UK
No, the start line is in there.
I've compared the script with one of the ones that does run and I cant see any differences in them.
The problem seems to be the way that the hotplug event is handled and the call for the device script is made.
If I look at my logs I get this information
Apr 24 11:53:36 marvin kernel: usb 1-2: Product: PocketPC SmartPhone
Apr 24 11:53:36 marvin kernel: usb 1-2: Manufacturer: Intel.
Apr 24 11:53:36 marvin kernel: usbserial 1-2:1.0: PocketPC PDA converter detected
Apr 24 11:53:36 marvin kernel: usb 1-2: PocketPC PDA converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
Apr 24 11:53:36 marvin /etc/hotplug/usb.agent: need a device for this command
Apr 24 11:53:36 marvin /etc/hotplug/tty.agent: add tty device /class/tty/ttyUSB0
Apr 24 11:53:42 marvin /etc/hotplug/usb.agent: /etc/hotplug/usb.agent: /etc/hotplug/usb/synce: /bin/bash^M: bad interpreter: No such file or directory
The script itself is
export time=`date +"%b %d %X"`
export uname=`uname -n`
echo "$time $uname $0: iPAQ added" >> /var/log/synce
synce-serial-abort >> /dev/null
synce-serial-start >> /var/log/synce
echo "export time=\`date +\"%b %d %X\"\`" >> $REMOVER
echo "export uname=\`uname -n\`" >> $REMOVER
echo "echo \"\$time \$uname $0: iPAQ removed\" >> /var/log/synce" >> $REMOVER
chmod +x $REMOVER
and its path is /etc/hotplug/usb/synce
If I type the command /etc/hotplug/usb/synce then it doesnt run. If I type
bash /etc/hotplug/usb/synce then it will.
There are other almost identical scripts in the same directory that will run without the bash command
^M: bad interpreter
looks to me like a DOS end of line character. I'd take a look at it in vim and see if editing that out makes a difference.
- LXF regular
- Posts: 143
- Joined: Thu Apr 07, 2005 6:15 pm
that looks as if you hit the nail on the head
Thanks very much for your help
Did you use chmod to make the script executable?
Return to Help!
Who is online
Users browsing this forum: Google [Bot], nelz and 1 guest