|
#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 |
![]() |
Tags |
backup , crt.screen.send , hostname , readstring , tftp |
Thread Tools | |
Display Modes | Rate This Thread |
|
|