Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-11-2013, 04:03 PM
chrismic1995 chrismic1995 is offline
Registered User
 
Join Date: Mar 2013
Posts: 10
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  
Old 03-11-2013, 05:01 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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  
Old 03-11-2013, 05:24 PM
chrismic1995 chrismic1995 is offline
Registered User
 
Join Date: Mar 2013
Posts: 10
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  
Old 03-12-2013, 08:03 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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  
Old 03-12-2013, 08:17 AM
chrismic1995 chrismic1995 is offline
Registered User
 
Join Date: Mar 2013
Posts: 10
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  
Old 03-12-2013, 09:05 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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>"
My suspicion is that you will see this displayed on two lines.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Closed Thread

Tags
backup , crt.screen.send , hostname , readstring , tftp

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 08:33 AM.