Technology Software

Linux Network Administrators Guide - Using chat to Automate Dialing

< Continued from page 1

facility.[1]

Specifying the chat script on the command line bears a certain risk because users can view a process's command line with the ps command. You can avoid this risk by putting the chat script in a file like dial-c3po . You make chat read the script from the file instead of the command line by giving it the –f option, followed by the filename. This action has the added benefit of making our chat expect sequences easier to understand.


To convert our example, our dial-c3po file would look like:

   

'' ATZ OK ATDT318714 CONNECT '' ogin: ppp word: GaGariN
When we use a chat script file in this way, the string we expect to receive is on the left and the response we will send is on the right. They are much easier to read and understand when presented this way.

The complete pppd incantation would now look like this:

   

# pppd connect "chat -f dial-c3po" /dev/ttyS3 38400 -detach \ crtscts modem defaultroute
Besides the connect option that specifies the dialup script, we have added two more options to the command line: –detach , which tells pppd not to detach from the console and become a background process, and the modem keyword, which makes it perform modem-specific actions on the serial device, like disconnecting the line before and after the call. If you don't use this keyword, pppd will not monitor the port's DCD line and will therefore not detect whether the remote end hangs up unexpectedly.

The examples we have shown are rather simple; chat allows for much more complex scripts.

For instance, it can specify strings on which to abort the chat with an error. Typical abort strings are messages like BUSY or NO CARRIER that your modem usually generates when the called number is busy or doesn't answer. To make chat recognize these messages immediately rather than timing out, you can specify them at the beginning of the script using the ABORT keyword:

   

$ chat -v ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ...
Similarly, you can change the timeout value for parts of the chat scripts by inserting TIMEOUT options.

Sometimes you also need to have conditional execution for parts of the chat script: when you don't receive the remote end's login prompt, you might want to send a BREAK or a carriage return. You can achieve this by appending a subscript to an expect string. The subscript consists of a sequence of send and expect strings, just like the overall script itself, which are separated by hyphens. The subscript is executed whenever the expected string it is appended to is not received in time. In the example above, we would modify the chat script as follows:

   

ogin:-BREAK-ogin: ppp ssword: GaGariN
When chat doesn't see the remote system send the login prompt, the subscript is executed by first sending a BREAK, and then waiting for the login prompt again. If the prompt now appears, the script continues as usual; otherwise, it will terminate with an error.

Notes



   [1]    

If you edit syslog.conf to redirect these log messages to a file, make sure this file isn't world readable, as chat also logs the entire chat script by default—including passwords.

   Prev    Home    Next
   Using Options Files    Up    IP Configuration Options



Related posts "Technology : Software"

How to Capture Analog Audio on My Computer

Software

Effective Photoshop Training Course to Enhance Your Photos

Software

How To Use Softphone Software For Your Business

Software

How to Access a String Array in JSP

Software

How Do I Get a Reversible Reaction Arrow in Microsoft Word 2007?

Software

How to Get AVCHD (MTS) Files to My PC

Software

Beat Detective Region Conform Tips

Software

MS BKF Repair Tool to Fix Corruption Owing to FAT File System

Software

Making an ASM Comparison

Software

Leave a Comment