| ![]() Ceroc Scotland Homepage |
| |||||||
| Geeks' Corner A place to hang out to solve all your computer, electronic, technical or telecommunication problems. Be warned that a strong bias towards Apple products will be shown by moderators / admins! |
| Quick News |
- Musicality workshop with Steve the Tramp Sunday 29th June. 12.00pm to 2.00pm. Followed by Tea-dance with DJ Tiggerbabe. Price: Only £16.00 for workshop + Tea-dance, Book online now! - Aberdeen Beach Ballroom week-end with Lucky & Ruby * IMPORTANT: POSTPONED DATE* 26th/27th July, A great selection of workshops from US Blues experts Lucky & Ruby Book online now! - Residential Focus BLUES Week-ender 5th/7th September. All inclusive 2 nights Dinner, Bed & Breakfast week-ender. 5 Focus classes on Blues with Franck Friday & Saturday late night parties open to everyone... With extra Blues Room on the Saturday night. Price: Early bird price: £139.00, Book online now! Upgrade your Forum experience, become a SILVER MEMBER! Benefits of Silver membership: - View what everyone is up to on the 'Who's online page, be invisible on the Forum, Create your own Blog, Remove Google Adverts, Filter new posts to avoid certain areas (e.g. Fun & Games, Chit Chat, Geek corner, etc...) when searching new posts, Send attachments in Private Messages, Chat room access , choose a custom avatar and have a Signature! + 4000 Private messages and tracking... Join today from as little as £6.00: Silver Member Subscriptions |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Ceroc Teacher Join Date: Jan 2005 Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Linux: automatic modem configuration Here's a question for the Linux experts: I have a tiny PC running Debian Linux as an unattended 'box'. it's attached to a network segment which also has a satellite transceiver; iEach host on the network that wishes to send data over the satellite link needs to telnet to the satellite unit and send a sequence of three AT commands before it can send any IP packets via the satellite. Normally these AT commands are sent by a piece of configuration software (a kind of control panel) that would run on each PC wishing to access the WAN. What I need to do is to create a script for the linux unit that will run automatically at startup to send the correct command sequence. By choice I'd probably use Expect because that's what it's designed for; but this Debian system is a minimalist install and probably doesn't have Expect. What else can I use, how would I write the script, and how would I make it run at startup? One complication is that the AT commands can take up to 60 or more seconds to return - usually with "OK" but possibly with an error. If an error is returned then I need the system to wait say 60 seconds then restart the script. The system has no screen, no keyboard and no possibility of user intervention, so I'm happy for it to keep trying the command sequence until it eventually succeeds. Clearly I'm not a Linux expert, so feel free to make as many obvious points as you wish - I'm bound to learn something. Thanks! |
| | |
| | #3 (permalink) |
| Lovely Moderator Join Date: Feb 2005 Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Off the top of my head... a wee shell script in /etc/rc1.d/ or similar... Call it "S99.modem-config". (The "99" might need to be smaller to get this to run before the rest of the network stuff...) (The proper way of doing this is to put the script in /etc/init.d/ and run update-rc.d, but I'm going to ignore that...) Here's a quick hacked-up script... Code: #! /bin/sh -
# what we're talking to...
MODEM=/dev/ttya
exec >$MODEM <$MODEM
function echook() {
echo "$@"
sleep 2
read a
test "$a" == "OK"
}
while true
do
sleep 60
echook "AT1111" || continue
sleep 10
echook "AT2222" || continue
sleep 10
echook "AT3333" || continue
break
done Hope this helps...
__________________ Let your mind go and your body will follow. – Steve Martin, LA Story |
| | |
| | #4 (permalink) |
| Ceroc Teacher Join Date: Jan 2005 Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Hi Ducasi, That's brilliant. The commands actually have to be passed over a telnet session to a particular address and port (192.168.128.100 port 1829, say) - how do I use a network socket rather than ttya? Also (not really related) question: how do I configure the unit to run a terminal session on serial port 1 so I can use a laptop with say, Hyperterminal to log in to the unit? Thanks! |
| | |
| | #5 (permalink) |
| Lovely Moderator Join Date: Feb 2005 Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration OK, assuming that the shell you are using is bash (echo $BASH_VERSION will tell you if it is), and things work as advertised, then here's a revised script: Code: #! /bin/bash -
# time-out on reads...
TMOUT=60
# what we're talking to...
HOST=host.name.or.ip.no
PORT=port#
MODEM=/dev/tcp/$HOST/$PORT
function echook() {
echo "$@"
sleep 2
read a
test "$a" == "OK"
}
while true
do
exec <>$MODEM >&0 && break
sleep 10
done
delay=1
while true
do
sleep $delay
delay=60
echook "AT1111" || continue
sleep 10
echook "AT2222" || continue
sleep 10
echook "AT3333" || continue
break
done To spawn a login prompt on one of the serial ports, edit /etc/inittab and see what is says... A Debian machine I'm using has this... Code: # /sbin/getty invocations for the runlevels. # # The "id" field MUST be the same as the last # characters of the device (after "tty"). # # Format: # <id>:<runlevels>:<action>:<process> # # Note that on most Debian systems tty7 is used by the X Window System, # so if you want to add more getty's go ahead but skip tty7 if you run X. # 1:2345:respawn:/sbin/getty 38400 tty1 2:23:respawn:/sbin/getty 38400 tty2 3:23:respawn:/sbin/getty 38400 tty3 4:23:respawn:/sbin/getty 38400 tty4 5:23:respawn:/sbin/getty 38400 tty5 6:23:respawn:/sbin/getty 38400 tty6 # Example how to put a getty on a serial line (for a terminal) # #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 # Example how to put a getty on a modem line. # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 Good luck!
__________________ Let your mind go and your body will follow. – Steve Martin, LA Story |
| | |
| | #6 (permalink) | |
| Registered User Join Date: Dec 2005 Location: Milton Keynes
Posts: 39
Rep Power: 2
Reputation Total: 39 ![]() | Re: Linux: automatic modem configuration Quote:
netcat is a wonderful tool: it essentially allows you to redirect stuff between arbitrary machines instead of pipelines on the same host. Wait: didn't I sign up to a dance forum thing to escape from computers? | |
| | |
| | #7 (permalink) | |
| Registered User Join Date: Mar 2003 Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741 ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
This geeky stuff is invaluable to some of us, and is one reason why we have the neg rep facility. ![]() | |
| | |
| | #8 (permalink) | |
| Registered User Join Date: Dec 2005 Location: Milton Keynes
Posts: 39
Rep Power: 2
Reputation Total: 39 ![]() | Re: Linux: automatic modem configuration Quote:
Would it help if I told you a bigger, older boy told bullied me into writing that? ![]() | |
| | |
| | #9 (permalink) |
| Lovely Moderator Join Date: Feb 2005 Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration I would have suggested using netcat, but bash seems to have enough TCP goodness built-in that it's not needed in this instance.
__________________ Let your mind go and your body will follow. – Steve Martin, LA Story |
| | |
| | #10 (permalink) | |
| Registered User Join Date: Mar 2003 Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741 ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
No, I had assumed it was a bigger older girl. ![]() (Actually I have passed the thread onto a geeky friend having a related problem ) | |
| | |
| | #11 (permalink) | ||
| Ceroc Teacher Join Date: Jan 2005 Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
Many thanks, everyone - much for me to work on here. Quote:
| ||
| | |
| | #12 (permalink) | |
| Registered User Join Date: Mar 2003 Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741 ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
![]() | |
| | |
| | #14 (permalink) | |
| Lovely Moderator Join Date: Feb 2005 Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
![]()
__________________ Let your mind go and your body will follow. – Steve Martin, LA Story | |
| | |
| | #15 (permalink) | |
| Registered User Join Date: Jul 2004 Location: London
Posts: 1,225
Rep Power: 2
Reputation Total: 500 ![]() ![]() ![]() ![]() ![]() ![]() | Re: Linux: automatic modem configuration Quote:
![]() | |
| | |
| Sponsored Links | |
Advertisement | |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux DVD to avi converter | Clive Long | Geeks' Corner | 2 | 24th-September-2006 09:46 PM |
| Where can I get a modem? | Ste | Geeks' Corner | 6 | 18th-August-2006 10:46 AM |
| Automatic Thread Subscription? | Rhythm King | Forum technical problems / Questions / Suggestions.. | 3 | 21st-January-2006 11:01 PM |
| Automatic Gender Balancing | Jeremy | Let's talk about dance | 52 | 10th-January-2006 04:25 PM |
| Win XP functionality / configuration | Bob | Geeks' Corner | 7 | 8th-January-2006 11:19 PM |