Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

shell script problems

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun Apr 24, 2005 10:37 am    Post subject: shell script problems Reply with quote

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
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8371
Location: Warrington, UK

PostPosted: Sun Apr 24, 2005 11:22 am    Post subject: RE: shell script problems Reply with quote

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:
#!/bin/bash

_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Apr 24, 2005 12:18 pm    Post subject: RE: shell script problems Reply with quote

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

PostPosted: Sun Apr 24, 2005 1:40 pm    Post subject: RE: shell script problems Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Sun Apr 24, 2005 2:00 pm    Post subject: RE: shell script problems Reply with quote

that looks as if you hit the nail on the head

Thanks very much for your help
Back to top
Guest






PostPosted: Tue May 17, 2005 6:58 pm    Post subject: RE: shell script problems Reply with quote

Did you use chmod to make the script executable?
Back to top
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast