[wplug] Passing AT commands direct to modem?

larry at daberko.com larry at daberko.com
Tue Feb 19 10:04:41 EST 2008


> On Mon, Feb 18, 2008 at 04:03:15PM -0500, larry at daberko.com wrote:
>> My employer is wanting to automatically forward our main lines to an
>> answering service after hours.  The answer was to set up a linux box to
>> dial the numbers needed.
>>
>> I have the AT command string and I tested it with cu -l /dev/ttyS0
>> interactively.  The string is:
>> ATDT*72W412-555-1234@;H
>> (for those who don't know... W=wait for dialtone, @=wait for silence)
>>
>> Now how do I send that via a script?  I don't see a way for cu to pass
>> the
>> string from the command line.  And for some reason, echo ATDT... >
>> /dev/ttyS0 has no effect.
>>
>> Linux Fedora Core 6 is the OS.
>>
>> I'm open to troubleshooting the echo issue or using another program.
>> This
>> is the last hurdle in my way.
>
> Actually, this sounds like a great use of the 'chat' program used for
> PPP and SLIP connections.
>
> If you don'tlike that, there's always 'cu' and 'expect'.
>
> --
> Jonathan Billings <wbanguna at gmail.com>
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>

Thanks for the suggestions!  I ended up using expect and cu to solve it. 
Excerpt from the code:

spawn cu -l /dev/ttyS0
expect "Connected."
sleep1
send "ATDT *72 412-555-1234\r"
expect
sleep 1
send "ATH\r"
expect "OK"
send "~.\r"
expect "Disconnected."
wait

The sleep commands seems to make the process run smoother.

LBD


More information about the wplug mailing list