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

Need help with Telnet using the connection directory

Status
Not open for further replies.

bcbm

Technical User
Sep 21, 2004
41
US
I need help with getting a script that will telnet to all telnet address's in the connection directroy and then send a few commands. Any help would be great.

Brian
 
The port number I placed in the connection directory after the IP address. Getting to the equipment is fine, but even with setting the echo at half duplex.

here's the error msgs I got

Error C002 Line 29: Missing space between tokens
Error C003 Line 29: Unexpected escape sequence
Error C002 Line 29: Missing space between tokens
Error C007 Line 29: New line character in constant
Error C001 Line 29: Missing terminating quote
Error C023 Line 29: Invalid expression token: M
Error C020 Line 29: Invalid token: "
"

Here is line 29

transmit "add user `"trial"`^M
 
Instead of placing it after the IP address, click on the Telnet Options tab and enter it in the Telnet Port field.

In the transmit string above, you have "` just before the ^M. It needs to be `" instead (everytime you escape a double quote it needs to be like that).

 
thanks for all the help, the script works great now. going to start working on getting it to e-mail out but not yet, lol. last question thou, can I run a BAT file out of the script ???
 
Yep, just use the run command to launch the batch file, get the task ID, and then use while taskexists to pause until the batch file is done. You can take a look at the taskexists discussion in the ASPECT help file to see more information on that.

 
This script is working great now, thanks for all the help. I just noticed that when it dials the seprate groups it goes through the group twice before moving on to the next group, any ideas. I'm using the example from above still.

proc main
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry

dialcount TELNET GROUP "LA_NAVS" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "LA_NAVS" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected
;do commands here
transmit "^M"
transmit "^M"
waitfor " Login:"
transmit "***^M"
waitfor " Password"
transmit "***^M"
waitfor ">"
transmit "alarms^M"
waitfor ">"
transmit "exit^M"

endif
endfor
endproc
 
Do you mean it is going through an entry more than once? Is it one that did not connect the first time through, or does it go through all of entries one after another? Can you post the dial code from your script if it differs greatly from above?

 
The script logs in and checks the alarms then once it hits the last entry for the direcoty it does it again before moving on to the next directory.


set capture file "LA_Nav" ;sets caputure file to the file named in file_date proc
capture on ;turns on capture

dialcount TELNET GROUP "LA_NAVS" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "LA_NAVS" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected

;do commands here
transmit "^M"
transmit "^M"
waitfor " Login:"
transmit "admin^M"
waitfor " Password"
transmit "Da7A6Y1^M"
waitfor ">"
transmit "alarms^M"
waitfor ">"
transmit "exit^M"

endif
endfor
capture off ;turns capture off

 
This bit of code looks to me like it will only run through the directory "LA_NAVS" once. Is this inside a larger loop?

If this program runs through several directories, then there must be more code.
 
I would agree with kodr, I created a group with some entries and ran the code above (just to get the name and print it using usermsg) and did not see any duplicate names.

 
here is the whole code, but pretty much what I pasted in is copied 4 times so I only pasted in the one section.


proc main
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry


set capture file "LA_Nav" ;sets caputure file to the file named in file_date proc
capture on ;turns on capture

dialcount TELNET GROUP "LA_NAVS" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "LA_NAVS" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected

;do commands here
transmit "^M"
transmit "^M"
waitfor " Login:"
transmit "***^M"
waitfor " Password"
transmit "****^M"
waitfor ">"
transmit "alarms^M"
waitfor ">"
transmit "exit^M"

endif
endfor
capture off ;turns capture off


set capture file "OC_Nav" ;sets caputure file to the file named in file_date proc
capture on ;turns on capture

dialcount TELNET GROUP "OC_NAVS" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "OC_NAVS" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected

;do commands here
transmit "^M"
transmit "^M"
waitfor " Login:"
transmit "***^M"
waitfor " Password"
transmit "***^M"
waitfor ">"
transmit "alarms^M"
waitfor ">"
transmit "exit^M"

endif
endfor
capture off ;turns capture off




set capture file "LA_Mux" ;sets caputure file to the file named in file_date proc
capture on ;turns on capture

dialcount TELNET GROUP "LA_MUXS" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "LA_MUXS" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected

transmit "^M"
waitfor " Login incorrect"
transmit "^M"
waitfor "Login:"
transmit "***^M"
waitfor " Password"
transmit "***^M"
waitfor ">"
transmit "alarms^M"
transmit "^M"
waitfor ">"
transmit "exit^M"

endif
endfor
capture off

set capture file "LA_AM" ;sets caputure file to the file named in file_date proc
capture on ;turns on capture

dialcount TELNET GROUP "LA_ANYMEDIA" iEntries ;Get number of entries in specified dialclass
for iCount = 0 upto (iEntries - 1)
dialname TELNET GROUP "LA_ANYMEDIA" iCount sName ;Get entry name corresponding to index number
statmsg sName
dial TELNET sName ;Make telnet connection
while $DIALING ;Loop while making connection
yield
endwhile
pause 1
if $CARRIER == 1 ;If connected

;do commands here
transmit "^M"
waitfor "login: "
transmit "^M"
waitfor "login: "
transmit "***^M"
waitfor "Password: "
transmit "***^M"
waitfor "<"
transmit "rtrv-alm-all;"
waitfor "<"
transmit ";"
transmit "canc-user::***;"

endif
endfor
capture off ;turns capture off


endproc
 
Give the below test script a try and see if you notice any duplication there. Basically it will just print the name of each entry in all four groups. If you don't see any duplication there, we would have to look at the dialing code next.

 
Probably helps if I hit Ctrl-V before I post:

Code:
proc main
   integer iEntries                    
   integer iCount                      
   string sName 

   dialcount TELNET GROUP "LA_NAVS" iEntriess
   for iCount = 0 upto (iEntries - 1)
      dialname TELNET GROUP "LA_NAVS" iCount sName      usermsg sName
   endfor

   dialcount TELNET GROUP "OC_NAVS" iEntries
   for iCount = 0 upto (iEntries - 1)
      dialname TELNET GROUP "OC_NAVS" iCount sName      usermsg sName
   endfor

   dialcount TELNET GROUP "LA_MUXS" iEntries
   for iCount = 0 upto (iEntries - 1)
      dialname TELNET GROUP "LA_MUXS" iCount sName       usermsg sName
   endfor

   dialcount TELNET GROUP "LA_ANYMEDIA" iEntries   
   for iCount = 0 upto (iEntries - 1)
      dialname TELNET GROUP "LA_ANYMEDIA" iCount sName      usermsg sName
   endfor
endproc

 
ok guys, thanks for the help. I figured out why I was getting double showings in my logs, it was appending to my old files. I didn't notice that the box to over write the existing file was not checked.
 
What I normally do, if I reuse file names, is to start by deleting the log file.

Code:
delfile "c:\test.txt"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top