| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sun Apr 24, 2005 10:37 am Post subject: shell script problems |
|
|
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
/etc/hotplug/usb/synce
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
Chris |
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 8036 Location: Warrington, UK
|
Posted: Sun Apr 24, 2005 11:22 am Post subject: RE: shell script problems |
|
|
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
_________________ "Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein) |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Apr 24, 2005 12:18 pm Post subject: RE: shell script problems |
|
|
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[7106]: need a device for this command
Apr 24 11:53:36 marvin /etc/hotplug/tty.agent[7108]: add tty device /class/tty/ttyUSB0
Apr 24 11:53:42 marvin /etc/hotplug/usb.agent[7106]: /etc/hotplug/usb.agent: /etc/hotplug/usb/synce: /bin/bash^M: bad interpreter: No such file or directory
The script itself is
#!/bin/bash
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
:> $REMOVER
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 |
|
| Back to top |
|
 |
fingers99 LXF regular
Joined: Thu Apr 07, 2005 7:15 pm Posts: 143
|
Posted: Sun Apr 24, 2005 1:40 pm Post subject: RE: shell script problems |
|
|
that | Quote: | | ^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. |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Apr 24, 2005 2:00 pm Post subject: RE: shell script problems |
|
|
that looks as if you hit the nail on the head
Thanks very much for your help |
|
| Back to top |
|
 |
Guest
|
Posted: Tue May 17, 2005 6:58 pm Post subject: RE: shell script problems |
|
|
| Did you use chmod to make the script executable? |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|