LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-30-2004, 02:30 AM   #1
the_cranky_don
LQ Newbie
 
Registered: Sep 2004
Location: Australia
Posts: 22

Rep: Reputation: 15
scripting woes slack9.0


i am having a bit of difficulty getting scripts to run in slack 9.0.

If i issue commands like 'sleep 1' and 'iwpriv wlan0 wlan_para channel=8' manually to get my wireless card working everything is ok.

i wrote a script to issue the commands for me.
it is as follows...

#! /bin/bash
#----------------------------------------------------
# Load Wireless LAN driver
#----------------------------------------------------

echo "Loading wireless LAN driver, please wait..."

insmod -f rtl8180_24x
sleep 1
iwpriv wlan0 wlan_para channel=8
sleep 1
iwpriv wlan0 wlan_para authtype=opensystem
sleep1
iwpriv wlan0 wlan_para ssid2scan=DONS_WIFI_ROUTER
sleep 1
iwpriv wlan0 wlan_para ssid=DONS_WIFI_ROUTER
sleep 1
#iwpriv wlan0 wlan_para preamble=long
#iwpriv wlan0 wlan_para networktype=infra
iwpriv wlan0 wlan_para basicrates=0xf,oprates=0xf
sleep 1
#
iwpriv wlan0 wlan_para encmode=off
sleep 1
iwpriv wlan0 wlan_para wepmode=off
sleep 1
#
ifconfig wlan0 192.168.0.12 netmask 255.255.255.0
sleep 1
#
iwpriv wlan0 enable

when i try to execute th script i get errors like

> wlanup
sh: /usr/bin/wlanup: /bin/bash
: bad interpreter: No such file or directory

i have tried using '#! /bin/sh' at the start of the script with no luck

i issued 'which bash' and got
/bin/bash

any help or hints would be appreciated
thanks,
Don =)
 
Old 10-30-2004, 03:38 AM   #2
bobbyseatbelt
LQ Newbie
 
Registered: Sep 2004
Location: hou
Distribution: slack
Posts: 14

Rep: Reputation: 0
try adding the full paths to the commands you want to run. if you continue to have problems do 'ls -la /bin/bash' and see if it points to something else. i'd also check the modify time of bash. maybe something changed?
 
Old 10-30-2004, 04:51 AM   #3
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Try: #!/bin/sh without the space, bash never worked for me in scripts
 
Old 10-30-2004, 09:04 PM   #4
the_cranky_don
LQ Newbie
 
Registered: Sep 2004
Location: Australia
Posts: 22

Original Poster
Rep: Reputation: 15
thanks for the replies,


here is the result of 'ls -la /bin/bash'

-rwxr-xr-x 1 root bin 628664 Sep 23 2002 /bin/bash

does this mean that bash is not present?


i laso did 'ls -la /bin/sh' and got

lrwxrwxrwx 1 root root 4 Aug 26 03:12 /bin/sh -> bash




I also tried '#!/bin/sh' without the space in the script and there was no change when i run it...

: bad interpreter: No such file or directory

thanks again,
Don =)
 
Old 11-02-2004, 01:27 AM   #5
LNXman
Member
 
Registered: Jul 2002
Location: California (USA)
Distribution: Slackware
Posts: 97

Rep: Reputation: 15
Re: scripting woes slack9.0

Quote:
Originally posted by the_cranky_don
i am having a bit of difficulty getting scripts to run in slack 9.0.

.
.
.

when i try to execute th script i get errors like

> wlanup
sh: /usr/bin/wlanup: /bin/bash
: bad interpreter: No such file or directory

i have tried using '#! /bin/sh' at the start of the script with no luck

i issued 'which bash' and got
/bin/bash

any help or hints would be appreciated
thanks,
Don =)
If you notice on the wlanup output, you have the error output line broken into two segments.

first segment is: sh: /usr/bin/wlanup: /bin/bash
second segment is: : bad interpreter: No such file or directory

when it should not be. To test write a test script file with just the line:

#!/bin/basho

and see the output of it (when you do this, use a *NIX editor like vi, or emacs).

Comparing your output, with the basho output, you can see that yours breaks at /bin/bash, which leads to the conclusion that the line where you define #!/bin/bash has a \r character appended at the end of it.

Another way to see this, is to run a trace of your script. To do that, you simple run your script like so:

sh -x ./wlanup

and then check the trace output.

How to fix?

delete the entire first line (i.e. #!/bin/bash), and re-write it.

However, from the looks of it, whichever editor you used to write your script, may have appended more \r characters on every line, which means, you may have to re-type the script using a *nix type editor.

Make sure you do not use any funky windows, type editor, otherwise the problem may happen again.

Hope this helped.

GL

//edit: added comment

Last edited by LNXman; 11-02-2004 at 01:28 AM.
 
Old 11-02-2004, 02:05 AM   #6
mcd
Member
 
Registered: Aug 2003
Location: Denver, CO
Distribution: CentOS, Debian
Posts: 825

Rep: Reputation: 33
wow, cool.
 
Old 11-03-2004, 12:36 AM   #7
the_cranky_don
LQ Newbie
 
Registered: Sep 2004
Location: Australia
Posts: 22

Original Poster
Rep: Reputation: 15
thanks for the help, LNXman.

i rewrote the script with vi and it worked well

what do you mean by a '\r' character being appended to the line, and how can i tell if this is the case?
 
Old 11-03-2004, 12:38 AM   #8
mcd
Member
 
Registered: Aug 2003
Location: Denver, CO
Distribution: CentOS, Debian
Posts: 825

Rep: Reputation: 33
did you try what he suggested? making a script with

#!basho


(hint: /r is carriage return, ie line break)

Last edited by mcd; 11-03-2004 at 12:40 AM.
 
Old 11-03-2004, 01:20 AM   #9
the_cranky_don
LQ Newbie
 
Registered: Sep 2004
Location: Australia
Posts: 22

Original Poster
Rep: Reputation: 15
yeah, that was only for testing purposes though
 
Old 11-03-2004, 02:27 AM   #10
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Most editors shows a "weird" character if the break character is not the one for Linux. Windows uses \r\n (#0D,#0A in hexadecimal or 13, 10 in decimal) as end characters for each line while linux uses only \n. As LNXman you may have used a editor which used Windows ending line characters when saving.
I don't know about other editors but mcedit (included in Slackware) shows ^M when it finds that "spare" character.
 
Old 11-03-2004, 04:56 AM   #11
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
you could use tr tool to convert dos to unix text :

cat file_in_dos.txt | tr -d "\r" > file_in_unix.txt
 
  


Reply



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
problem N slack9.1 huno Slackware 5 11-04-2006 04:00 PM
scripting woes Pestossimo Linux - Newbie 3 07-20-2005 12:43 PM
webmin, slack9.1 tcaptain Slackware 3 11-06-2003 09:12 AM
should I have gtkspell-2.0 with slack9.1 shanenin Linux - Software 1 10-17-2003 06:04 PM
slack9.0 ?!?! Crunch Slackware 3 03-05-2003 10:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:51 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
Open Source Consulting | Domain Registration