LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Help debugging adsl dial script. (https://www.linuxquestions.org/questions/linux-networking-3/help-debugging-adsl-dial-script-506474/)

djsbriscoe 12-01-2006 03:54 AM

Help debugging adsl dial script.
 
Hi,
I have got as far as getting my speedtouch 330 (Revision 4) to connect the internet by following the instructions on

http://www.linux-usb.org/SpeedTouch/ubuntu/index.html

I am using Kubuntu Edgy 6.10

I tested the setup by entering the following command

# sudo pppd call speedtch

This resulted in a successful connection. Fine so far.

I then issued the following command to shut down pppd

# sudo killall pppd

and followed up with the command

# sudo /etc/init.d/dial

The result of the last command was:

/etc/init.d/dial:line 5:while[[0-lt 40]]: command not found
/etc/init.d/dial:line 6:syntax error near unexpected token 'do'
/etc/init.d/dial:line 6:'do'

The bash script 'dial' is as follows

#!/bin/bash
modprobe ppp_generic
modprobe pppoatm
count=0
while [[ $((count++)) -lt 40 ]]
do
sync=$(dmesg | grep 'ADSL line is up')
if [ ! -z "$sync" ]
then
pppd call speedtch
exit 0
fi
sleep 1
done
echo "The SpeedTouch firmware did not load"

I would appreciate some help in debugging the above script or finding another way of connecting automatically at boot time.

Thanks,

David :)

unSpawn 12-01-2006 07:45 AM

Maybe something like:
Code:

#!/bin/sh
# /bin/sh is linked Bash(2) on GNU/Linux
count=0
modprobe ppp_generic
modprobe pppoatm
while [ $count -lt 40 ]; do
 # Find in syslog (default) this string once with time range of one minute:
 string="^`/bin/date "+%b.%e %H:%M"`.*ADSL line is up"
 grep -q -m1 "$string" /var/log/messages
 case "$?" in
  0) # If we find the string execute ppd and alert if it failed to load.
      pppd call speedtech && exit 0 || echo "The SpeedTouch firmware did not load";;
  *) # If we dont find the string increment the count and sleep.
    ((count++)); sleep 1;;
 esac
done
exit 0

Not tested so YMMV(VM).

osvaldomarques 12-01-2006 02:49 PM

Hi djsbriscoe,

I don't have that hardware but the script is very simple and should work. I copied it and commented the portions that are not of interest for the error you are reporting and it worked without any problem.

However, looking for the error line, it seems that you copied the script from the site to show us and your actual has little differences; I see that you didn't respect the space separation on the while line:
Code:

/etc/init.d/dial:line 5:while[[0-lt 40]]: command not found
This means that the contents of the line 5 is
Code:

while[[$((count++))-lt 40]]
instead of
Code:

while [[ $((count++)) -lt 40 ]]
If I'm right on this supposition, edit the file inserting the spaces that the script will work.

Osvaldo.


All times are GMT -5. The time now is 09:38 AM.