PDA

View Full Version : piping a generated file into the telnet session


jyoungta
11-04-2004, 07:36 AM
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

rlpm
11-08-2004, 10:33 AM
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):
> 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

jyoungta
11-08-2004, 01:13 PM
Cool, Thanks I'll try it out.

-JYT

hardcopy
11-25-2004, 10:36 AM
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):
> 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?

rlpm
11-29-2004, 05:47 PM
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

hardcopy
11-30-2004, 03:06 AM
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

rlpm
11-30-2004, 07:49 AM
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

czoeller
12-15-2004, 01:54 PM
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

czoeller
12-15-2004, 02:21 PM
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

rlpm
12-16-2004, 08:39 AM
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