Author Topic: What\'s wrong with this executable bash script?  (Read 3611 times)

toadatrix

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
    • http://
What\'s wrong with this executable bash script?
« on: March 10, 2004, 12:34:01 pm »
I made up the following script to automate starting up wellenreiter.  I am running a C860 using the new Cacko ROM (release 1.20 March 5).  I am trying to run the script in Konsole after doing an su - to run as root.  The commands all work perfectly if I type them into the Konsole keyboard.  I entered the following text into ZEditor and saved the file in the /home/zaurus directory as wellenreiter_startup.  I then then did the following to try to make it executable:

cd /home/zaurus
chmod 755 wellenreiter_startup

However, when I try to run it from Konsole (after doing su - and a cd /home/zaurus) I get the following error:

bash:  wellenreiter_startup:  command not found

Here is the script file:

#!/bin/sh

cd /etc/pcmcia
mv wlan-ng.conf .wlan-ng.conf
mv .hermes.conf hermes.conf
cardctl eject
/etc/rc.d/init.d/pcmcia restart
cardctl insert
cardctl scheme CardResume
cardctl scheme qpewlan0
cardctl reset
iwconfig
wellenreiter

OK, so what is wrong here that the script doesn\'t run.  One place I saw that I should also do

./wellenreiter_startup

But that didn\'t seem to have any effect.  Someone else said I need to use dos2unix to convert the script (that sounds strange to me).  Please, linux experts let me know what I did wrong and how to get the script to run.  Thanks.

ChanSecodina

  • Newbie
  • *
  • Posts: 12
    • View Profile
What\'s wrong with this executable bash script?
« Reply #1 on: March 10, 2004, 12:47:17 pm »
You either need to put it in a directory listed in your PATH or you need to run it with the complete path to the binary ( /home/zaurus/wellenreiter_startup ) or you need to cd into the same directory as it and run it as ./wellenreiter_startup.    Any of these should work.  To see what directories are listed in your PATH:

echo $PATH

Just off of the top of my head, /usr/bin seems like an ok place to put it.

-John

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
What\'s wrong with this executable bash script?
« Reply #2 on: March 10, 2004, 12:55:49 pm »
Quote
Someone else said I need to use dos2unix to convert the script (that sounds strange to me).

That was me. You only need to do this to strip out the line feeds (if you created the file on a Windows machine or used the Sharp text editor program), otherwise Linux scripts get confused by them.

You must have noticed the converse on a Windows machine if you download a file which was created on a Linux box it all appears on one line with little black squares in between where the line breaks should be - Windows uses CRLF as the end of line whereas Linux uses only CR (I think, though I may have the Linux one wrong).


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

raybert

  • Full Member
  • ***
  • Posts: 233
    • View Profile
What\'s wrong with this executable bash script?
« Reply #3 on: March 10, 2004, 03:32:30 pm »
Linux and Unix use just LF.
dos2unix strips the CRs.
You can see them in vi, if they\'re there.  They show up as ^M.

~ray