Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-07-2014, 10:55 AM   #1
LQ Newbie
Registered: Oct 2008
Posts: 1

Rep: Reputation: 0
Linux Chat - Handling Errors via Subexpect Pairs

Good morning,

I'm still very new to Linux, and am writing a script that needs to connect to possibly several different modem models.

I want to disable 4g on modems that support that mode. As such, I would have a set of lines like this:

''      'ATZ'
'OK' 'AT+4GMODE=0'  #disable the 4g mode, where supported
So since not all modems will support that command, the next line would be use a subexpect clause:

'OK-AT-OK' 'ATDT#12345678" #dummy phone number of course
My expectation is that the 4g disable would return 'OK' where supported, otherwise would return 'ERROR'. To handle that 'ERROR' the chat would send 'AT' and expect 'OK'.

This works for connecting a modem that supports the 4g command. However, for a 3g-only modem, it breaks. I've got a tool that allows me to send commands manually to the modem and check the response. For both modems, AT does return OK.

Do the subexpect/subsend pairs not work to handle a returned ERROR, then?

I apologize if this is in the wrong forum...I thought about the networking forum, but since I'm still very new I thought maybe I'm missing something that would be obvious to experienced users. I've looked at the man page for chat, but did not see anything that sheds light on this. I searched this forum and found one other old thread with a similar problem, but I still can't figure out where mine is going wrong.

Thanks and have a great day!
Old 05-15-2014, 02:36 AM   #2
Andy Alt
Registered: Jun 2004
Location: Minnesota, USA
Distribution: Slackware32-stable, Debian32 stable, LFS 7.1
Posts: 385

Rep: Reputation: 44
I'm not familiar with chat scripting, but I believe I've found an appropriate reference page.

May I ask what you are using for documentation?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows chat client communicates with Linux server chat application friend511 Linux - Newbie 1 05-16-2012 07:56 AM
Handling Errors and exceptions of commands pdklinux79 Linux - Newbie 1 06-20-2008 03:28 PM
errors while handling sys_unlink dypgrp Linux - General 0 02-01-2005 10:57 AM
linux file handling errors class_struggle Linux - Newbie 1 07-26-2004 06:31 PM
Exception handling compilation errors ashwinipahuja Programming 6 07-03-2004 07:46 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration