Blaze II The Ceroc Scotland week-ender
Blaze 2008, Ayr 9/12th May 2008:
The Ceroc Scotland 3-nights Week-ender

Ceroc Scotland Forum

Ceroc Scotland Homepage

 

Go Back   Ceroc Scotland Forum > Discussion Lounge > Geeks' Corner
Mark Forums Read

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

Reply
 
LinkBack Thread Tools Display Modes
Old 10th-March-2006, 12:52 AM   #1 (permalink)
El Salsero Gringo
Ceroc Teacher
 
El Salsero Gringo's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374
El Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud of
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!
El Salsero Gringo is offline   Reply With Quote
Old 10th-March-2006, 01:14 AM   #2 (permalink)
WittyBird
The Gobby one!
 
WittyBird's Avatar
 
Join Date: Aug 2005
Location: Geekville
Posts: 6,871
Rep Power: 5
Reputation Total: 3072
WittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to beholdWittyBird is a splendid one to behold
Re: Linux: automatic modem configuration

Think your problem is the fact that its tiny but will ask the other guru's tomorrows
WittyBird is offline   Reply With Quote
Old 10th-March-2006, 01:21 AM   #3 (permalink)
ducasi
Lovely Moderator
 
ducasi's Avatar
 
Join Date: Feb 2005
Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224
ducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to behold
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
Some tweaking, maybe a "stty" or two, but that is all that you really need...

Hope this helps...
__________________
Let your mind go and your body will follow. – Steve Martin, LA Story
ducasi is offline   Reply With Quote
Old 10th-March-2006, 08:36 AM   #4 (permalink)
El Salsero Gringo
Ceroc Teacher
 
El Salsero Gringo's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374
El Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud of
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!
El Salsero Gringo is offline   Reply With Quote
Old 10th-March-2006, 09:31 AM   #5 (permalink)
ducasi
Lovely Moderator
 
ducasi's Avatar
 
Join Date: Feb 2005
Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224
ducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to behold
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
I've never used bash's "/dev/tcp" built-in networking, so I'm not 100% sure that it'll work... Because I'm now using bash-specific features, I've changed the script to specify bash explicitly.

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
Theoretically, uncommenting one of those "Tx" lines should do the right thing... Consult the man pages for inittab and getty for more details.

Good luck!
__________________
Let your mind go and your body will follow. – Steve Martin, LA Story
ducasi is offline   Reply With Quote
Old 10th-March-2006, 09:10 PM   #6 (permalink)
tomboh
Registered User
 
tomboh's Avatar
 
Join Date: Dec 2005
Location: Milton Keynes
Posts: 39
Rep Power: 2
Reputation Total: 39
tomboh is on a distinguished road
Re: Linux: automatic modem configuration

Quote:
Originally Posted by El Salsero Gringo
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?
Do you mean a telnet session as opposed to a TCP port? The telnet protocol uses funky characters to auto-negotiate stuff (yeah, I'm not quite sure what) and while you may need to do this, if you're thinking along the lines of "connect to port 80 for HTTP', use netcat(1). On Debian you'll need to do an "apt-get install netcat" if it's not already installed.

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?
tomboh is offline   Reply With Quote
Old 10th-March-2006, 09:25 PM   #7 (permalink)
bigdjiver
Registered User
 
Join Date: Mar 2003
Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741
bigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of light
Re: Linux: automatic modem configuration

Quote:
Originally Posted by tomboh
...Wait: didn't I sign up to a dance forum thing to escape from computers?
This geeky stuff is invaluable to some of us, and is one reason why we have the neg rep facility.
bigdjiver is offline   Reply With Quote
Old 10th-March-2006, 09:31 PM   #8 (permalink)
tomboh
Registered User
 
tomboh's Avatar
 
Join Date: Dec 2005
Location: Milton Keynes
Posts: 39
Rep Power: 2
Reputation Total: 39
tomboh is on a distinguished road
Re: Linux: automatic modem configuration

Quote:
Originally Posted by bigdjiver
This geeky stuff is invaluable to some of us, and is one reason why we have the neg rep facility.
Really, talking about computers might make me unpopular? I never knew! I kept wearning the pointy hat and standing in the corner because I thought it would make everyone love me.

Would it help if I told you a bigger, older boy told bullied me into writing that?
tomboh is offline   Reply With Quote
Old 10th-March-2006, 09:34 PM   #9 (permalink)
ducasi
Lovely Moderator
 
ducasi's Avatar
 
Join Date: Feb 2005
Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224
ducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to behold
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
ducasi is offline   Reply With Quote
Old 10th-March-2006, 10:06 PM   #10 (permalink)
bigdjiver
Registered User
 
Join Date: Mar 2003
Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741
bigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of light
Re: Linux: automatic modem configuration

Quote:
Originally Posted by tomboh
... Would it help if I told you a bigger, older boy told bullied me into writing that?
No, I had assumed it was a bigger older girl.

(Actually I have passed the thread onto a geeky friend having a related problem )
bigdjiver is offline   Reply With Quote
Old 11th-March-2006, 12:47 AM   #11 (permalink)
El Salsero Gringo
Ceroc Teacher
 
El Salsero Gringo's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 4,881
Rep Power: 4
Reputation Total: 2374
El Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud ofEl Salsero Gringo has much to be proud of
Re: Linux: automatic modem configuration

Quote:
Originally Posted by tomboh
Do you mean a telnet session as opposed to a TCP port?
Quite right - I was being sloppy. I meant a TCP port.


Many thanks, everyone - much for me to work on here.

Quote:
Originally Posted by tomboh
Wait: didn't I sign up to a dance forum thing to escape from computers?
There is *no* escape.
El Salsero Gringo is offline   Reply With Quote
Old 11th-March-2006, 01:09 AM   #12 (permalink)
bigdjiver
Registered User
 
Join Date: Mar 2003
Location: bedford
Posts: 3,701
Rep Power: 3
Reputation Total: 741
bigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of lightbigdjiver is a glorious beacon of light
Re: Linux: automatic modem configuration

Quote:
Originally Posted by bigdjiver
No, I had assumed it was a bigger older girl.
Ah, the joys of windows. Now it is possible to mess up 4 things more or less simultaneously
bigdjiver is offline   Reply With Quote
Old 15th-March-2006, 10:34 PM   #13 (permalink)
Andreas
Registered User
 
Join Date: Jul 2004
Location: London
Posts: 1,225
Rep Power: 2
Reputation Total: 500
Andreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of light
Re: Linux: automatic modem configuration

Quote:
Originally Posted by El Salsero Gringo
There is *no* escape.
How about '/'?
Andreas is offline   Reply With Quote
Old 15th-March-2006, 11:34 PM   #14 (permalink)
ducasi
Lovely Moderator
 
ducasi's Avatar
 
Join Date: Feb 2005
Location: Glasgow
Posts: 9,500
Rep Power: 6
Reputation Total: 3224
ducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to beholdducasi is a splendid one to behold
Re: Linux: automatic modem configuration

Quote:
Originally Posted by Andreas
How about '/'?
This is Linux we're talking about here, so I think you mean "\" (or even just "^[".)
__________________
Let your mind go and your body will follow. – Steve Martin, LA Story
ducasi is offline   Reply With Quote
Old 16th-March-2006, 07:50 AM   #15 (permalink)
Andreas
Registered User
 
Join Date: Jul 2004
Location: London
Posts: 1,225
Rep Power: 2
Reputation Total: 500
Andreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of lightAndreas is a glorious beacon of light
Re: Linux: automatic modem configuration

Quote:
Originally Posted by ducasi
This is Linux we're talking about here, so I think you mean "\" (or even just "^[".)
Got me there.
Andreas is offline   Reply With Quote
Sponsored Links
Advertisement
 
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


The time in sunny Scotland is 10:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0
vB Ad Management by =RedTyger=

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18