home *** CD-ROM | disk | FTP | other *** search
- <******************************************************* language=slang
-
- Sample SLANG Modem Dialup Script
-
- Description:
-
- Medium Example #2 -- Written in the SLANG scripting language
-
- In this script (basically the same as Medium Example #1) we
- are using the "define" built-in function to consolodate the
- phone number and all the modem commands. Since they are in
- one place, at the top of the script, we can find and change
- them easily, instead of hunting through-out the script. This
- is useful if a different phone number is to be used, or if
- you switch to a modem of a different type.
-
- This script dials the modem. It then checks "polls" the
- serial line to see if the modem has connected with the remote
- modem.
-
- If the connection has been made the script enters a user-id
- after a short delay, then a password after another short
- delay and, finally, packet mode is enabled so enable TCP/IP
- data transfers. The last thing the script does is run two
- DOS applications: PCMAIL and VMAIL. VMAIL is left running
- after the script is done.
-
- If no connetion is made the script informs the user and ends.
-
- This script does not store a user id or password directly,
- but uses the ones that were entered in WDial's Configuration
- Window.
-
- To Use This Script:
-
- Change "0000" to the phone number of the remote machine you
- would like to connect to.
-
- Be sure the enter your password and user id in WDial's
- Configuration Window.
-
- Adjust the intervals in the (pause,...) functions to suit
- your needs. These are in milliseconds (5000 milliseconds ==
- 5 seconds).
-
- This script assumes that your modem, and the remote host,
- terminate commands with an ASCII Carrage-Return character.
- If, instead, a Carrage-Return/Line-Feed (CRLF) is required,
- change "(cr)" to "(cr)(lf)" everywhere in the script it is
- necessary.
-
- Notes:
-
- This is a very simple dial script. It assumes that, once the
- modem connection has been made the following will be true:
-
- o the remote machine will always be ready for your
- user-id after a set interval
-
- o like-wise for your password
-
- It is more robust than simpler examples in that it checks to
- see if the modem connected or not, and acts accordingly.
- There is no provision for retries, or verification of the
- remote host, all of which are possible in SLANG. The script
- also assumes that there will be a user id and password prompt
- after set intervals.
-
- Note that the send function calls in the "hang-up" do not
- have curly braces around the modem commands. Curly braces
- are no necessary in this case because the modem commands are
- one word (not containing spaces, tabs, newlines or commas).
- Here is what you see:
-
- (send, ATH (cr) )
-
- What is sent consists of the letters 'A', 'T', 'H', and the
- ASCII Carrage-return character.
-
- Built-In SLANG Functions Used:
-
- define Define a function.
- send Send a character string to the modem.
- poll Wait for the serial line to change state.
- pause Wait a specified number of milliseconds.
- username Return username from WDial's Configuration Window.
- password Return password from WDial's Configuration Window.
- shell Run a program, wait until program is done running.
- start Run a program, don't wait for it to complete.
- changemode Changes mode of connection from "raw" to
- "packet".
-
- ************************************************************************>
-
- (define, PHONE# , 0000 ) <* Phone number to dial *>
- (define, DIAL , ATDT ) <* Modem dial command *>
- (define, HANGUP , ATH ) <* Modem hang up command *>
- (define, RESET , ATZ ) <* Modem initialization command *>
- (define, ATTN , +++ ) <* Modem attention command *>
-
- (define, dial-up, { <* START OF "dial-up" FUNCTION *>
- (send, <* Dial the remote modem/host *>
- (value, DIAL) <* Modem command *>
- (value, PHONE#) <* Phone number *>
- (cr) <* Carrage-Return after modem cmd *>
- ) <* End of "send" function *>
- }) <* END OF "dial-up" FUNCTION *>
-
- (define, log-in, { <* START OF "log-in" FUNCTION *>
- (poll, physical, open, 30000, <* Wait for the modem to connect *>
- { <* IF THE MODEM CONNECTED SUCESSFULLY *>
- (pause, 3000) <* Wait for remote machine's prompt *>
- <* Log-in to the remote modem/host *>
- (send, (username) ) <* Send your user id *>
- (send, (cr) ) <* Carrage-Return after user id *>
- (pause, 5000) <* Wait for a password prompt *>
- <* Send the password *>
- (send, (password) ) <* Send password *>
- (send, (cr) ) <* Carrage-Return after password *>
- (pause, 5000) <* Pause for a moment *>
- (changemode, packet) <* Change to "packet" mode *>
-
-
- } <* END IF THE MODEM CONNECTED *>
-
- , <* Comma delimits "Else" part of poll *>
-
- { <* ELSE IF THE MODEM DOSN'T CONNECT *>
- (output, {
-
- The Modem didn't connect. End of Script.
-
- } <* everything between { } displayed *>
- ) <* End of the "output" function *>
- (hang-up) <* Reset the modem *>
- (exit) <* Exit the script *>
- } <* END IF THE MODEM DOESN'T CONNECT *>
- ) <* End of the "poll" function *>
- }) <* END OF "log-in" FUNCTION *>
-
- (define, run-my-programs, { <* START OF "run-my-programs" FUNCTION *>
- (shell,pcmail) <* Run mailer *>
- (start,vmail) <* Run mail reader *>
- }) <* END OF "run-my-programs" FUNCTION *>
-
- (define, hang-up, { <* START OF "hang-up" FUNCTION *>
- (send, (value, ATTN) ) <* Get modem's attention *>
- (pause, 3000 ) <* Wait 3 seconds for modem response *>
- (send, (value, HANGUP)(cr)) <* Send "hang up" command to modem *>
- (pause, 1000 ) <* Give modem 1 second to do it *>
- (send, (value, RESET) (cr)) <* "Zero" modem *>
-
- }) <* END OF "hang-up" FUNCTION *>
-
-
- <************************* RUN THE SCRIPT *****************************>
-
- ( dial-up ) <* DIAL THE REMOTE MODEM *>
- ( log-in ) <* LOG IN, STOP SCRIPT HERE IF FAILURE *>
- ( run-my-programs ) <* RUN PROGRAMS WHILE LOGGED IN *>
- ( hang-up ) <* HANG UP AND RESET THE MODEM *>
-