Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-04-2004, 07:36 AM
jyoungta jyoungta is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
Question piping a generated file into the telnet session

Hi, I have the task to configure 300 switches and am looking for an easier way of doing it. Currently I have written a script for cygwin which generates a configuration file based on some initial input arguments. Is there a way to basically do the following "cat configfile | telnet 10.0.0.1". I have tried the above and unfortunately it doesn't work . I am doing alpha testing for the 5.0 so if its a feature in there I could try it too.

Thanks in advance

-JYT
Reply With Quote
  #2  
Old 11-08-2004, 10:33 AM
rlpm's Avatar
rlpm rlpm is offline
VanDyke Developer
 
Join Date: Jun 2004
Location: Albuquerque, NM
Posts: 69
Lightbulb Script for dumping a file to multiple telnet hosts

JYT,

I have created a SecureCRT script that will open a telnet session to each of a list of hosts, and dump a file to that session.

1) Create a "hosts" file with one host per line.
2) Create a single "raw" file to dump to those hosts.
3) Edit the script file to point to the files created in steps #1 and #2.
By default, they are "c:\tmp\hosts.txt" and "C:\tmp\raw.txt", respectively.
4) Run the script (replacing path as necessary):
Code:
> securecrt /SCRIPT c:\tmp\multihostdump.txt
This should be a good starting point if you need to dump a different file to each host.

Regards,
--rlpm
Attached Files
File Type: txt multihostdump.txt (1.7 KB, 349 views)
Reply With Quote
  #3  
Old 11-08-2004, 01:13 PM
jyoungta jyoungta is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
Cool, Thanks I'll try it out.

-JYT
Reply With Quote
  #4  
Old 11-25-2004, 10:36 AM
hardcopy hardcopy is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
will not work

Quote:
Originally Posted by rlpm
JYT,

I have created a SecureCRT script that will open a telnet session to each of a list of hosts, and dump a file to that session.

1) Create a "hosts" file with one host per line.
2) Create a single "raw" file to dump to those hosts.
3) Edit the script file to point to the files created in steps #1 and #2.
By default, they are "c:\tmp\hosts.txt" and "C:\tmp\raw.txt", respectively.
4) Run the script (replacing path as necessary):
Code:
> securecrt /SCRIPT c:\tmp\multihostdump.txt
This should be a good starting point if you need to dump a different file to each host.

Regards,
--rlpm
I tried it out but the script will not proceed to the next IP address.
Any ideas?
Reply With Quote
  #5  
Old 11-29-2004, 05:47 PM
rlpm's Avatar
rlpm rlpm is offline
VanDyke Developer
 
Join Date: Jun 2004
Location: Albuquerque, NM
Posts: 69
Question Error message?

Hardcopy,

I'm sorry to hear that this script is not working for you. Unfortunately, we need more information to help you out.

1) Did you modify the script to specify the szHostsFile and szRawFile?
2) Did you modify the script in any other ways?
3) Did the telnet session to the first IP address succeed?
4) Did you receive an error message when trying to run the script?

Regards,
--rlpm
Reply With Quote
  #6  
Old 11-30-2004, 03:06 AM
hardcopy hardcopy is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
Quote:
Originally Posted by rlpm
Hardcopy,

I'm sorry to hear that this script is not working for you. Unfortunately, we need more information to help you out.

1) Did you modify the script to specify the szHostsFile and szRawFile?
2) Did you modify the script in any other ways?
3) Did the telnet session to the first IP address succeed?
4) Did you receive an error message when trying to run the script?

Regards,
--rlpm
Hi rlmp,

thanks for your reply but I was able to keep the script running so far.
The problem was (I guess) the line crt.screen.WaitForKey(1) when the EOF of the RAW file has been reached :
crt.screen.Send szText & vbcrlf
' wait for a keystroke (really just wait one second)
crt.screen.WaitForKey(1)
Loop
fileRaw.Close

I moved the line to the beginning of the loop and the script was running through.

Any thoughts why this happend?

cheers Adrian
Reply With Quote
  #7  
Old 11-30-2004, 07:49 AM
rlpm's Avatar
rlpm rlpm is offline
VanDyke Developer
 
Join Date: Jun 2004
Location: Albuquerque, NM
Posts: 69
Thumbs up Glad it's working

Quote:
Originally Posted by hardcopy
thanks for your reply but I was able to keep the script running so far.
...
I moved the line to the beginning of the loop and the script was running through.

Any thoughts why this happend?
Adrian,

I'm glad you resolved the problem. I'm not sure why the WaitForKey call would have been causing the problem.

Could you please tell me which version of SecureCRT/CRT you are using?

Thanks,
--rlpm
Reply With Quote
  #8  
Old 12-15-2004, 01:54 PM
czoeller czoeller is offline
Registered User
 
Join Date: Dec 2004
Posts: 2
what if telnet fails?

i have tried this script and it works, though what if one of the devices in the host file fails to conect via telnet. the script dies if that happends to me. can someone give me a sample if/then as a workaround to the sample given?
thanks,
clark
Reply With Quote
  #9  
Old 12-15-2004, 02:21 PM
czoeller czoeller is offline
Registered User
 
Join Date: Dec 2004
Posts: 2
never mind

never mind i found the answer...
On Error Resume Next <-- add this line above
crt.session.connect("/telnet " & szHost)

anyone know how to then log the ip address that failed?

clark







what if telnet fails?

--------------------------------------------------------------------------------

i have tried this script and it works, though what if one of the devices in the host file fails to conect via telnet. the script dies if that happends to me. can someone give me a sample if/then as a workaround to the sample given?
thanks,
clark
Reply With Quote
  #10  
Old 12-16-2004, 08:39 AM
rlpm's Avatar
rlpm rlpm is offline
VanDyke Developer
 
Join Date: Jun 2004
Location: Albuquerque, NM
Posts: 69
Thumbs up New script attached

Clark,

I'm glad that you found "On Error Resume Next". I should have included that in the original script.

I've added connect failure logging to the attached script.

I hope this helps,
--rlpm
Attached Files
File Type: txt multihostdump.txt (2.0 KB, 306 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:27 AM.