# (c) AutoJini.com. All Rights Reserved. # Released under MITT. Give credit where it is due ############################# # ++++ CONFIGS +++++++ ############################## # change these dialinno = 15555555555 username = autojini password = ******** savetofile = data.xml # com port of your modem modemCom = 3 # open file to write to... w+ option creates a new file. File = [open $savetofile w+] #count numbers of lines so we only send cariage return #after we have processed minimum of 10-20 lines... #used in our writeXMLFile procedure below. i = 0 # set a variable to check for 1 = terminial then we start the # regular expression other wise we will match on things we don't need okayToRunRegExp = 0 #=================================================== # ACTUAL CODE... MODIFY AS NEEDED #=================================================== # Define callback procedure proc writeXMLFile line { # global variables... anything else in procedure is local global File range i okayToRunRegExp # lets make sure that we don't capture any of the report stuff or anything before... # we know 1= Terminal 2 = Print is our end of report create stuff... and anything # after that is our data that we need... so we look for that line # if we find it we set okayToRun to 1 and start our processing # if you are lost on regex then checkout http://www.regular-expressions.info/ if {[regexp (.*)(Terminal)(.*) $line] == 1} { okayToRunRegExp = 1 puts $File "" } # we keep ignoring untill okay to run if {$okayToRunRegExp == 1} { #find the line it is... and split and ouput as xml if {[regexp (STOCK-NO\.)(\s*)(.*) $line] == 1} { regsub (STOCK-NO\.)(\s*)(.*)($) $line \\3 stockNo puts $File "$stockNo" } elseif {[regexp (STOCK-TYPE)(\s*)(.*) $line] == 1} { regsub (STOCK-TYPE)(\s*)(.*)($) $line \\3 stockType puts $File "$stockType" } elseif {[regexp (STATUS)(\s*)(.*) $line] == 1} { regsub (STATUS)(\s*)(.*)($) $line \\3 status puts $File "$status" } elseif {[regexp (SERIAL)(\s*)(.*) $line] == 1} { regsub (SERIAL)(\s*)(.*)($) $line \\3 serial puts $File "$serial" } elseif {[regexp (ENTRY)(\s*)(.*) $line] == 1} { regsub (ENTRY)(\s*)(.*)($) $line \\3 entry puts $File "$entry" } elseif {[regexp (INT-COLOR)(\s*)(.*) $line] == 1} { regsub (INT-COLOR)(\s*)(.*)($) $line \\3 icolor puts $File "$icolor" } elseif {[regexp (COLOR)(\s*)(.*) $line] == 1} { regsub (COLOR)(\s*)(.*)($) $line \\3 ecolor puts $File "$ecolor" } elseif {[regexp (YR)(\s*)(.*) $line] == 1} { regsub (YR)(\s*)(.*)($) $line \\3 year puts $File "$year" } elseif {[regexp (TRANS)(\s*)(.*) $line] == 1} { regsub (TRANS)(\s*)(.*)($) $line \\3 transmission puts $File "$transmission" } # check when we have reached the end of our report... # end of report is reached when we are back to run report screen # we need to find a unique word on that screen and look for it. found = [regexp (SY502E.*) $line] # we found our ending... clost the root element... # flush to file... # close file... and log off the system if {$found == 1} { puts $File flush $File close $File capture stop session close return } # process only if we have gone threw 15 lines... other wise increment. # okay remember we have to press enter to get next screen of data.. # so press enter but first flush all the data in buffer to file # set our numbers of lines processed to zero.. # if we have not processed 15 lines then increment our line count if { $i > 15 } { flush $File send i = 0 } else { i = [expr $i + 1] } } } #the actual dial up stuff... sets our com port, baud rate, stop bits and others. set comm-type com set port-number $modemCom set baud-rate 57600 set parity 8 none set stop-bits 1 set protocol-type xonxoff # open our session.. if open then continue other wise exit. ok = [session open] if {$ok == 0} {return} #dial and wait for connect message send "atdt$dialinno" wait string "CONNECT" conFound = [wait start] #did not connect throw message and close session if {$conFound == 0} {message "not able to connect";session close;return} #connected press enter and wait for account prompt send wait string "ENTER YOUR USER ID/ACCOUNT NAME" lpFound = [wait start] #did not find account prompt throw message and close session if {$lpFound == 0} {message "login not found";session close;return} #send user name send "$username" #wait for system to ask for password wait string "Password" lpFound = [wait start] #password not found... kill.. kill.. kill if {$lpFound == 0} {message “Password not found”;session close;return} #password found found send send "$password" #wait 5 sec for the system to log us in.. and display welcome message #could be changed to wait for some string wait 5 seconds #send enter to continue after welcome message send #should be on the ESP screen so select RPG as the first option send #go down a bit and select the report our report is first one... so only one down send #select our report send #run our report send "r" #will ask for terminal and print... terminal is default so just press enter. send #now start the capture capture start writeXMLFile