# Trumpet Winsock Logon Script # ---------------------------- # (for the Alachua Freenet, ver.1.1) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # * Trumpet Winsock script and data stream scanning routines written * # * by and (c) 1999 William H. Oldacre (oldacre@afn.org). Please * # * use freely, do not charge for it's distribution, and give credit * # * to the original author if modified for your own use. * # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # Make sure the modem is in command mode and send the initialization # string from the Setup option in Trumpet's 'File' menu. If none is # present, we'll assume the user wants the modem setup left alone and only # add a couple of commands that must be present for proper dialup linkage # (&C1, &D2). Exit gracefully if the modem doesn't respond. # Trace on # Troubleshooting? Turn trace on here! output +++ sleep 2 if ! [load $modem_init] $modem_init = "AT &C1 &D2" end output $modem_init\r if ! [input 10 OK] $answer = "Please click Cancel or press " query $answer "Modem not responding, check com port setup!" abort end # Display phone number, username, and state whether or not a password # exists without displaying it. Offer opportunity to make changes, but # simply press to continue if none desired. Remind users to prefix # their phone number with "*70," to defeat the call waiting feature on # their phone service. load $number load $username if [load $password] $passstat = "(hidden)" else $passstat = "None" end display \n\n" Dialup number = "$number\n" Username = "\u\n" Password = "$passstat\n $answer = "N" query $answer "Change phone, username, or password (N,y)?" $answer = upper($answer) if $answer = "NO" $answer = "N" end if ! [load $number] | $answer <> "N" display \n"If you have call waiting, prefix your number with "\""*70,"\" display \n"or incoming calls may break your Freenet connection!"\n query $number "Enter an AFN number to dial (see note below)" save $number end if ! [load $username] | $answer <> "N" username "Enter your AFN username" save $username end if ! [load $password] | $answer <> "N" password "Enter your AFN password" save $password end # Load and dial the phone number from the trumpwsk.ini file and then # repeatedly scan the incoming data stream for BUSY, NO CARRIER, NO # DIALTONE, or CONNECT messages in any order or in combination with # any other text. Discard any extraneous garbage text without # choking on it. If more than 100 attempts have been made, politely # ask user whether or not to continue. If the answer is Yes, just # press . Press "N" or "n" to quit the script entirely. %maxtrys = 100 # If you wish to make more or fewer %attempts = 0 # dialling attempts, change the # %maxtrys = nnn line! repeat $result = "" %attempts = %attempts + 1 output ATDT$number\n %exitloop = 0 repeat read 60 $result if pos("NO DIALTONE", $result) $answer = "Y" query $answer "No dialtone, check phone line. Retry (Y,n)?" $answer = upper($answer) if $answer = "Y" %exitloop = 1 else abort end end if pos("BUSY", $result) display "Line is busy, retrying"\n output ath0\n %exitloop = 0 sleep 3 end if pos("NO CARRIER", $result) display "No answer, retrying!"\n %exitloop = 1 sleep 3 end if pos("CONNECT", $result) %exitloop = 1 end until %exitloop if %attempts = %maxtrys $answer = "Y" query $answer "No success logging on, keep trying (Y,n)?" $answer = upper($answer) if $answer = "N" abort else %attempts = 0 end end until pos("CONNECT", $result) #! Optional Script #! --------------- #! This elegant bit of script will search the data stream for the Username, #! Password, and other prompts in any order, discarding confusing logon #! messages. It can be modified to respond to almost any array of prompts #! it encounters as long as the prompt strings end with a linefeed (0Ah) #! character. If any prompt does not end with a linefeed, this script #! fragment will hang and cannot be used. Sorry, but that's the way the #! Trumpet "read nn $s1" command works. It is provided here in the event it #! will prove useful to someone. If -you- find a way to work around this #! limitation please let me know and I'll include it in future (free) #! distributions. (W. Oldacre) #! #! %logdone = 0 #! repeat #! read 40 $result #! if pos("Login:", $result) #! output $username\n #! end #! if pos("Username:", $result) #! output $username\n #! end #! if pos("Password:", $result) #! output $password\n #! end #! if pos("AFN-TS", $result) #! output "3"\n #! %logdone=1 #! end #! if pos("Make your selection:", $result) #! output "2"\n #! %logdone=1 #! end #! until %logdone # This much less flexible script section merely expects the Username, # Password, and protocol selection prompts in order. Prompts must match # explicitly, but no terminating linefeeds are required (see above). Here, # the script ends with the expectation (prayer) that the user has properly # established SLIP or PPP settings in the File/Setup menu. Van Jacobson # CSLIP compression will sometimes permit a successful logon, but may # interfere with the transfer of data packets. Suggest user consider # this when trouble shooting. input 60 "sername:" output $username\n input 60 "assword:" output $password\n input 60 "AFN-TS" if %ppp output "3"\r display \n"PPP mode chosen based on your selection in the File/Setup menu."\n display "Your IP address is: "\i\n else output "2"\r input 30 "IP address is" address 30 display \n\n"SLIP mode chosen based on your selection in the File/Setup menu."\n display "If you experience difficulty, try turning off Van Jacobson CSLIP"\n display "compression in the File/Setup menu!"\n end display \n"* * * * Connected! Start your browser NOW! * * * *"\n\n # [Script Ends]