Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the cu command whith PERL 1

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hi,

I am trying to use the "cu" command (UNIX command) in a script. With that, i want to send requests (AT, ATI, AT1...) to a modem, in a asynchron line, and I want to get the response back, in a file for example.

My pb is that it is impossible to get the response back.

And I don't know how to do...

For example, if, in shell, i use the command :

cu -l /dev/cua/b -s 9600 - b 8 > zzz

I can type the commands AT, ATI, AT1, and then ~. (to quit the connection by cu).
Then, if i look in the zzz file, i have

connected
AT
OK
ATI
...
...
Disconnected

I would like to integrate this in a perl script, and moreover i want to get the word "OK" for example...

Can anyone help me ?????

 
One way would be to open a pipe to the 'cu' command like:

open(CU, "| cu -l /dev/cua/b -s 9600 - b 8 > zzz 2>&1") or die "Can't open pipe: $! \n";
print CU "AT\n";
print CU "ATI\n";
close(CU);
open(F, "zzz") or die "Can't open zzz: $! \n";
while(<F>) {
# Parse output
}
close(F);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top