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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modem testing script

Status
Not open for further replies.

Salman228

IS-IT--Management
Dec 18, 2005
2
US
Dont know much about Procomm or Aspect scripting.

Need to write a script that will test 600 modem connections. These modems are used for out of band access to various routers.

assuming i have a text file with the phone numbers in this format:

8175555555
2145555555
9725555555
etc

The following sample script from aspectscripting.com is very helpful, but I need to tweek it a little:

proc main
string sNum

if fopen 0 "numbers.txt" READ TEXT ;Open text file containing list of connections
while not feof 0 ;While data remains in the file
fgets 0 sNum ;Get entry from file
if not nullstr sNum ;If entry is not blank
dial DATA sNum ;Then dial it
while $DIALING ;Pause while dialing
yield
endwhile
if $CARRIER ;If connected...
;perform operations here once connected...
endif
endif
endwhile
endif
fclose 0 ;Close data file
endproc

What I need is a method to notate success or failure of the dial in attempt and write it back to the text file so that the completed text file may look like this:

8175555555 P
2145555555 F
9725555555 P

Where 'P' or 'F' indicates pass or fail of the dial in test. I think there is a line or two that I need to add here:
if $CARRIER ;If connected...
;perform operations here once connected...
endif

But I do not know how to write to the text file. '

Anyhelp would be greatly appreciated.

Thanks,
 
I think it would be best to write to a different output file, otherwise you would have to some tweaking of the text to insert the status to make sure you read the next number correctly.

To do, add this line after the first fopen:

fopen 1 "results.txt" WRITE TEXT

and change the if $CARRIER structure to read:

if $CARRIER
strfmt sOut "%s P" sNum
else
strfmt sOut "%s F" sNum
endif

and finally add the end, add an fclose 1 after the fclose 0 to close your results file.
then after the endif

 
Thanks a bunch knob.

Here is the final script, (if you don't mind checking it over real quick)..


proc main
string sNum

if fopen 0 "numbers.txt" READ TEXT ;Open text file containing list of connections
fopen 1 "results.txt" WRITE TEXT ; create results.txt output file

while not feof 0 ;While data remains in the file
fgets 0 sNum ;Get entry from file
if not nullstr sNum ;If entry is not blank
dial DATA sNum ;Then dial it
while $DIALING ;Pause while dialing
yield
endwhile
if $CARRIER ;If connected...
strfmt sOut "%s P" sNum ;output P if connected
else
strfmt sOut "%s F" sNum ; output F if not connected
endif
endif
endwhile
endif
fclose 0 ;close data file
fclose 1 ;close results file
endproc


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top