LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux Chat - Handling Errors via Subexpect Pairs (https://www.linuxquestions.org/questions/linux-newbie-8/linux-chat-handling-errors-via-subexpect-pairs-4175504210/)

czardragon 05-07-2014 09:55 AM

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:

Code:

''      '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:

Code:

'OK-AT-OK' 'ATDT#12345678" #dummy phone number of course
'CONNECT'

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!

Andy Alt 05-15-2014 01:36 AM

I'm not familiar with chat scripting, but I believe I've found an appropriate reference page.
http://www.tldp.org/HOWTO/PPP-HOWTO/x1219.html

May I ask what you are using for documentation?


All times are GMT -5. The time now is 08:56 AM.