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!