Sponsored Content
Operating Systems Linux How do I capture responses from the chat command? Post 302494736 by Bashingaway on Tuesday 8th of February 2011 08:29:01 AM
Old 02-08-2011
Quote:
Originally Posted by DGPickett
Google chat.c, there is a bsd version with a -r option for a report file, or you can add it. There is an inactive sourceforge file. Some versions send the dialog to syslog.
The version I'm using is supposed to support the REPORT file, however I'll be darned if I can get it to work.....

If I could find any working examples I could at least try to see if my syntax is correct.....

for example..

Code:
chat -Vs ' ' 'AT+CGMI' 'OK' ' ' > $COMPORT < $COMPORT

gives me the response

Code:
Ericsson

OK

However

Code:
chat -Vsr /path/to/outputfile REPORT ' ' 'AT+CGMI' 'OK' ' ' > $COMPORT < $COMPORT

gives me

Code:
Failed

I've tried variations on where to place the word REPORT without success.....it's annoying to be honest.

---------- Post updated at 01:29 PM ---------- Previous update was at 01:25 PM ----------

Quote:
Originally Posted by Corona688
What function does 'chat' serve in this? You should just be able to talk to the modem.

Code:
#!/bin/sh
# set up modem device to translate outgoing \n into \r\n
stty -F /dev/ttyS0 9600 -echo igncr icanon onlcr
# Open modem for reading and writing
exec 5</dev/ttyS0
exec 6>/dev/ttyS0

echo "AT+CGMI" >&6

# Eat the echo, then eat the blank line
read <&5 ; read <&5
# Read the actual response
read RESPONSE <&5

echo "Response was $RESPONSE"

# close the files
exec 5<&-
exec 6>&-

Code:
$ ./modem.sh
Response was ERROR
$

...mine returns 'ERROR' because it's not a cellphone so AT+CGMI means nothing to it. It responds 'OK' to plain 'AT'. Works in BASH, KSH, and ASH. If you have trouble, try 'cat <&5' to see what it's printing.

I had thought about going this way but the problem is that if the modem throws anything other then what's expected I could miss the error...for example (understandably) the normal response requires dropping the first two lines from read <&5 however if there's an error state I may never get to see it.

What I really want to do is capture all the response from the modem and then start to code the analysis of said response.

Thanks for the idea but hopefully you can see my concern.
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

talk command to chat

Hi, Could you please advice on the following query: There are 2 users on a unix box: 1. aaaa 2. bbbb I open 2 putty sessions and login with the above 2 users. Then I type the following using the aaaa user to chat with bbbb. talk bbbb or talk bbbb@hostname Result: the screen goes... (1 Reply)
Discussion started by: miltonkeynesguy
1 Replies

2. UNIX for Dummies Questions & Answers

talk command to chat

Hi, Could you please advice on the following query: There are 2 users on a unix box: 1. aaaa 2. bbbb I open 2 putty sessions and login with the above 2 users. Then I type the following using the aaaa user to chat with bbbb. talk bbbb or talk bbbb@hostname Result: the screen goes... (4 Replies)
Discussion started by: miltonkeynesguy
4 Replies

3. UNIX for Dummies Questions & Answers

Doing a capture while another command is executing?

Basically what i'm trying to do is execute an update command and at the same time have the system do a TCPdump to file for that update traffic. So I would like to connect the two commands so that the tcpdump terminates automatically when the update finishes/fails/whatever. Right now I have... (0 Replies)
Discussion started by: MrEddy
0 Replies

4. Web Development

Can you embed Skype or any other video chat/chat program into a webpage?

Hi, I am trying to embed Skype or any other video chat/chat program into a webpage. Has anyone had success doing this? or know how? Thanks Phil (2 Replies)
Discussion started by: phil_heath
2 Replies

5. What is on Your Mind?

Very Funny and Somewhat Amazing 2006 Chat Bot Chat

Working on the badging system, Just found this old thread for 2006 and started reading it. ROTFL ... what a great discussion between forum members and our chat bot Gollum "back in the good old days"... You must check this out if you want a laugh and big smile: ... (1 Reply)
Discussion started by: Neo
1 Replies
All times are GMT -4. The time now is 02:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy