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 10-27-2006, 03:32 AM
samoki samoki is offline
Registered User
 
Join Date: Jun 2006
Posts: 24
[Help]Script send command error and get unexpected output

I write a script,part underside:
Dim result,flag
flag = 0
crt.Screen.Send VbCr
While flag = 0
result = crt.Screen.WaitForStrings ("(config)#","#","[Y/N]","$",10)
Select Case result
Case 1
crt.Screen.Send "exit" &VbCr
flag = 0
Case 2
crt.Screen.Send "exit" &VbCr
flag = 0
Case 3
flag = 0
crt.Screen.Send "y" &VbCr
Case 4
flag = 1
'Write log login ok
Case Else
flag = 1
'Write log login failed due to unknown error.
End Select
Wend

This part is used to logout from router and return to my Unix station.When router give "[Y/N]",program can recognise,but do not run sentence "crt.Screen.Send "y" &VbCr".

The output is underside:
(config)#
17:11:49:40 10/27/2006
(config)#exit
17:11:49:350 10/27/2006
#exit
You'd better save the configuration data before exit.
Exit without save? [Y/N]e
[Y/N]e
[Y/N]Y
17:11:49:860 10/27/2006Connection closed by foreign host.
$ Y
Y: not found
$
How can I return to my Unix station correctly

Last edited by samoki; 10-29-2006 at 06:16 PM.
Reply With Quote
  #2  
Old 10-27-2006, 09:40 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Do you run crt.screen.synchronous at the beginning of the script?

Are you running this script in a window with multiple tabs?

In the output it appears that the letter 'e' character being sent, and I don't see where in the script this would be sent. Could you send the entire script and the entire output to support@vandyke.com and reference this forum thread?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #3  
Old 10-29-2006, 06:40 PM
samoki samoki is offline
Registered User
 
Join Date: Jun 2006
Posts: 24
I cann't give you full program,because the program occured error is a alone sub program.The part of program I given can explain all.There is any useful sentences in other parts of the program.I think "e" is the "e" in "exit",this is the point that why I say then sentece "crt.Screen.Send "y" &VbCr" is not be runned.And I believe that some sentence "crt.Screen.Send "exit" &VbCr" is running by mistake because when router ask "[Y/N]" only one character will be received,so when the program sent "exit" only "e" be received.After that, we'll see the wrong output.
By the way,the sentence "crt.Screen.Send "y" &VbCr" is running once by mistake at last yet(We can see it at last of the output).I think that it occur due to the same reason.

Last edited by samoki; 10-29-2006 at 06:45 PM.
Reply With Quote
  #4  
Old 10-30-2006, 07:05 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
If it's not possible to send the entire script then hopefully some general debugging help will be useful. You're probably correct about the 'e' being part of the Crt.Screen.Send "exit" command.

Can you popup a msgbox "result = " & result after the Crt.Screen.WaitForStrings as a sanity check just to make sure you know where the 'e' might be coming from?

Do you run crt.screen.synchronous at the beginning of the script?

Are you running this script in a window with multiple tabs?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #5  
Old 10-31-2006, 12:04 AM
samoki samoki is offline
Registered User
 
Join Date: Jun 2006
Posts: 24
First I answer your last two questions:

1.I run crt.screen.synchronous = True at the beginning of the script.

2.I run the script in a window with single tab mode.

I have used two way to test the program if something wrong include your idea(Thanks).The answer is everything is right,"result=" returns right value,program point to the right "case" sentence(I use msgbox function in every "case" section).But when output is "$",program go to "case 3",the "crt.Screen.Send "y" &VbCr" is not be run correctly,in SecureCRT,word "e" input,and the error occured.
Reply With Quote
  #6  
Old 10-31-2006, 04:59 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Which version of SecureCRT are you using (Help / About SecureCRT)?

Using version 5.2 official release I ran the script you originally posted, and used the output you showed us to drive the script. In each case the script reaches the correct case statement and sends the correct text. So, I'm not sure what the problem could be.

Is it possible that WaitForStrings is timing out (10 seconds)?

In the sample output you posted, there's a capital letter 'Y' but the script would only send a lower case letter 'y'. So, there's a capital letter 'Y' that's not sent by the script, and a lower case 'e' which could be sent by the script as part of the "exit" command, but doesn't seem likely since it looks like there is a CR after the 'e', not additional letters.

Could you show the output you see if you don't use the script, but manually type the data that should be sent so that we can see correct output?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #7  
Old 11-14-2006, 08:13 PM
samoki samoki is offline
Registered User
 
Join Date: Jun 2006
Posts: 24
Now I post output by manually type:

(config)#
10:27:55:700 11/15/2006
(config)#exit
10:27:58:770 11/15/2006
#exit
You'd better save the configuration data before exit.
Exit without save? [Y/N]y
10:28:2:180 11/15/2006Connection closed by foreign host.
$

It's the route output by manually type,I only delete the host name in output for security.

Otherwise,I use WaitForStrings for 10 seconds,because some kinds of routers need long response time possible,I must consider this possibility in large net.

I use SecureCRT's version is 5.1 official release.

In the end,the "y" in program & "Y" in output is not a problem.I test the program for a long time,I fixed my program in the course and the information I given is copy from log file in forepart test.

Last edited by samoki; 11-14-2006 at 08:16 PM.
Reply With Quote
  #8  
Old 11-16-2006, 09:55 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Quote:
I fixed my program in the course
Does this mean your script is working correctly now?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #9  
Old 11-17-2006, 12:54 AM
samoki samoki is offline
Registered User
 
Join Date: Jun 2006
Posts: 24
Quote:
Originally Posted by miked
Does this mean your script is working correctly now?
I'm sorry,I mean when I test my program,I revamp the program continually,but it still can't run correctly.
It's so strange.
I just tested my program again,and used "msgbox" to label what output that program recognised,when crt output "[Y/N]",msgbox command put a correct box,and in securecrt the input is "e"
output:

15:45:9:860 11/17/2006
(config)#exit
15:45:10:110 11/17/2006
#exit
You'd better save the configuration data before exit.
Exit without save? [Y/N]e 'Here program recognised [Y/N],I press "Enter" bottom,and program input "e"
[Y/N]y
15:45:10:630 11/17/2006Connection closed by foreign host.
$ y Here "y" input again
y: not found
$

Last edited by samoki; 11-17-2006 at 01:22 AM.
Reply With Quote
  #10  
Old 11-17-2006, 06:57 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Can you try version 5.2 just in case you're running into a problem caused by version 5.1?

Your script looks okay to me and runs as expected when I enter the keyword data manually: (config)#, #, [Y/N], $. Are you testing your script by typing the keyword data manually, by cat'ing keyword data, or is the data generated by the device you're working with?

If you type the keyword data manually do you get desired behavior?

Here is the VBScript I was using, based on your script.

Code:
Dim result,flag
crt.screen.synchronous = true
flag = 0
crt.Screen.Send VbCr 
While flag = 0 
	result = crt.Screen.WaitForStrings ("(config)#","#","[Y/N]","$",10) 

	Select Case result
		Case 0
			msgbox "timed out"
			flag = 0
		Case 1, 2
			crt.Screen.Send ("exit" & vbcr)
			msgbox "1 or 2"
			flag = 0 
		Case 3 
			crt.Screen.Send ("y" & vbcr) 
			msgbox "3"
			flag = 0
		Case 4 
			flag = 1
			'Write log login ok 
			msgbox "4"
		Case else
			flag = 1 
			'Write log login failed due to unknown error.
			msgbox "unknown error"
	End Select
Wend
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]

Last edited by miked; 11-22-2006 at 09:30 AM.
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 03:22 AM.