#1
|
|||
|
|||
Readstring and crt.Screen.Send backup to TFTP issue.
All, I am trying to automate the backup process of over a hundred layer 2 WWP/Ciena switches, however when I run the following script below, it paste in the "tput 10.70.28.199 " hits ENTER and then tries to run the rest of the script.
I am gathering the hostname of the switch and using it as the filename on the TFTP server. ____________________________________________________________________________________________________ ___________________________ Script #$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True ' This automatically generated script may need to be ' edited in order to work correctly. Sub Main hostname = crt.Screen.ReadString(">") crt.Screen.Send "tput 10.70.28.199 " & hostname & " /flash0/config/startup-config" & chr(13) End Sub ____________________________________________________________________________________________________ ___________________________ Here is the results of running the script LIBRARY-3920-CE> tput 10.70.28.199 ERROR: Incomplete tftp command LIBRARY-3920-CE> LIBRARY-3920-CE /flash0/config/startup-config SHELL PARSER FAILURE: 'LIBRARY-3920-CE' - invalid input LIBRARY-3920-CE> ____________________________________________________________________________________________________ ___________________________ And here is me manually running the command LIBRARY-3920-CE> LIBRARY-3920-CE> tput 10.70.28.199 LIBRARY-3920-CE /flash0/config/startup-config LIBRARY-3920-CE> Any thoughts, I did notice that I have to hit ENTER to start the script, I believe that is what helps "match" the ReadString for the hostname... |
#2
|
|||
|
|||
Hello chrismic1995,
If you have to manually hit "ENTER" to kick things off, then the script is out of sync from the beginning. ![]() It makes sense because the first item you are waiting for (in this case with ReadString()) is probably already displayed as part of the shell prompt. How are you running the script? If you put that "initial ENTER" into the script, what are the results? Code:
Sub Main crt.Screen.Send vbcr hostname = crt.Screen.ReadString(">") crt.Screen.Send "tput 10.70.28.199 " & hostname & " /flash0/config/startup-config" & chr(13) End Sub
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Thanks Brenda, however that still did not work? As expected you corrected the issue of having to hit the ENTER key but when the script runs it still outputs the command "tput 10.70.28.199" first, hits ENTER and then tries to run the rest of the command instead of running it all in one line?
Thanks, CM |
#4
|
|||
|
|||
Hi chrismic1995,
Sorry, I left out an entire line of code when posting my response yesterday. The problem is the "ENTER" you are sending to "kick off" the script is being captured as part of the ReadString(). So you want to send the CR via the script and also wait for it. Code:
Sub Main crt.Screen.Send vbcr crt.Screen.WaitForString vbcr hostname = crt.Screen.ReadString(">") crt.Screen.Send "tput 10.70.28.199 " & hostname & " /flash0/config/startup-config" & chr(13) End Sub
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
Thanks Brenda, but it is still not working? Here is what the results were and what I have in my script:
LIBRARY-3920-CE> LIBRARY-3920-CE> tput 10.70.28.199 ERROR: Incomplete tftp command LIBRARY-3920-CE> LIBRARY-3920-CE /flash0/config/startup-config SHELL PARSER FAILURE: 'LIBRARY-3920-CE' - invalid input LIBRARY-3920-CE> #$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True ' This automatically generated script may need to be ' edited in order to work correctly. Sub Main crt.Screen.Send vbcr crt.Screen.WaitForString vbcr hostname = crt.Screen.ReadString(">") crt.Screen.Send "tput 10.70.28.199 " & hostname & " /flash0/config/startup-config" & chr(13) End Sub Thanks, CM |
#6
|
|||
|
|||
Hi CM,
What protocol are you using to connect? The "CR" is still being included in what is being sent for some reason. You will plainly see this if you change the "send" line to a message box instead. For example: Code:
MsgBox "<tput 10.70.28.199 " & hostname & " /flash0/config/startup-config>"
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
I am using Telent, here is a screen shot of the MsgBox.
Thanks for the support... CM |
#8
|
|||
|
|||
Also, I am using Version 7.0.2 (build 418) SecureCRT..
Thanks, CM |
#9
|
|||
|
|||
Hi CM,
That may explain it. If you enable Force character at a time mode in the Connection / Telnet category of SecureCRT's Session Options, what are the results?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#10
|
|||
|
|||
I changed that for my default session option, closed out SecureCRT and re-opened and tried it again but still no go? Please see the attachment as an example.
Thanks, CM |
#11
|
|||
|
|||
Hi CM,
I'm a bit confused. So you are making an ad hoc connection (via Quick Connect), not using a saved session, correct? Still, there is a line return being included (before hostname) in the send command. Would you use the attached example script to message box what you are capturing with ReadString so we can see what non-printing characters or escape sequences are included?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#12
|
|||
|
|||
Do I need to edit your script and place my Sub Main in place of the crt.Screen.Send portion?
Sub Main() strPrompt = "]-->" crt.Screen.Synchronous = True crt.Screen.Send "ls --color *.sh *.gz" strReceivedData = crt.Screen.ReadString(strPrompt) crt.Dialog.MessageBox RevealNonPrintingCharacters(strReceivedData) End Sub _____________________________________________________________ I am making a quick connection and yes a RETURN is being inputted before the "hostname". If I remove the variable and place a static name everything works just fine, it places it all on one line. Thanks, CM |
#13
|
|||
|
|||
Hi CM,
Yes, pretty much. This example script is intended to see what is going on with your code. Alter it (the RevealNonPrintingCharacters example script) as shown below: Code:
Sub Main() crt.Screen.Synchronous = True crt.Screen.Send vbcr crt.Screen.WaitForString vbcr strReceivedData = crt.Screen.ReadString(">") crt.Dialog.MessageBox RevealNonPrintingCharacters(strReceivedData) End Sub
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#14
|
|||
|
|||
The attached has the output from the test script..
Thank you... CM |
#15
|
|||
|
|||
Hi CM,
Sorry, bear with me a moment while I adjust my dunce cap. ![]() In your original script, change the WaitForString to vbcrlf, what are the results?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
backup , crt.screen.send , hostname , readstring , tftp |
Thread Tools | |
Display Modes | Rate This Thread |
|
|