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 09-25-2016, 02:06 AM
jakjok jakjok is offline
Registered User
 
Join Date: Sep 2016
Posts: 3
python sending enter key over telnet

HI,


i'm not able to send "enter" key for after accessing the access server, i need to type the device name and hit enter ... till here its working .... after this .. i need to send another enter key .. looks like my script new line but not the enter key


Code:
objNewTab = crt.Session.ConnectInTab("/TELNET ###.###.#.## 23")

      if objNewTab.Session.Connected:
        objNewTab.Screen.Synchronous = True
        objNewTab.Screen.WaitForString("sername:")
		#objNewTab.Screen.Send(user1 + "\r")
		#objNewTab.Screen.Send(password + "\r")
		#objNewTab.Screen.Send("redacted" + "\r")
		#objNewTab.Screen.Send("redacted" + session + "\r")
        #objNewTab.Screen.Send("redacted" + rackNumber + session + "\r")
        objNewTab.Screen.Send(user1 + "\r")
        objNewTab.Screen.WaitForString("assword:")
        objNewTab.Screen.Send(password + "\r")
        objNewTab.Screen.Send("\r")
        objNewTab.Screen.Send("\r")
        objNewTab.Screen.Send("\r\n")
        objNewTab.Screen.Send("\n")
        objNewTab.Screen.Send("\n\r")
        objNewTab.Screen.Send(session)  
        objNewTab.Screen.Send("\r")   /// i need to send enter after this line ...
        objNewTab.Screen.Send("\n\r")
        objNewTab.Screen.Send("\r\n")
        objNewTab.Screen.Send("\r")
        objNewTab.Screen.Send("\r")
        #objNewTab.creen.sendKeys("[enter]")
        #objNewTab.Screen.Send(VbCr)
        #objNewTab.Screen.Send chr(13)
        objNewTab.Screen.Send(chr(13))
        objNewTab.Screen.Send('{ENTER}')
        objNewTab.Screen.Send(chr(13))
        objNewTab.Screen.Send("{ASC 065}")
        objNewTab.Screen.Send('{ASC 2709}')
        objNewTab.Screen.Send('{ASC 2709}')
        objNewTab.Screen.Send('{ASC 2709}')
        objNewTab.Screen.Send('{ASC 2709}')
        objNewTab.Screen.Send("{ASC 065}")
        objNewTab.Screen.Send("{ASC 065}")
        objNewTab.Screen.Send("{ASC 065}")
        objNewTab.Screen.Send("{ASC 065}")
        objNewTab.Screen.Send(chr(13))
        objNewTab.Screen.Send(chr(13))
        objNewTab.Screen.Send("\r")
...it shows that its sending new line . but not the enter KEY:

++++++++++++++++++++++++++++++
Code:
Username: 

User Access Verification

Username: redacted
Password:                                                                                              


PDX-03#R1
Translating "R1"
Trying r1 address #1 ... 
% Connection refused by remote host

PDX-03#
PDX-03#R4
Translating "R4"
Trying asa4 address #1 ... Open
+++++++++++++++++++++++++++++++++++++++


while it should send the enter KEY and i need to be like this :


Code:
Username: 

User Access Verification

Username:redacted
Password:                                                                                              


PDX-03#R1
Translating "R1"
Trying r1 address #1 ... 
% Connection refused by remote host

PDX-03#
PDX-03#R4
Translating "R4"
Trying asa4 address #1 ... Open



R4>


thanks in advance

Last edited by bgagnon; 09-26-2016 at 08:29 AM.
Reply With Quote
  #2  
Old 09-26-2016, 09:01 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,015
Hi jakjok,

The "\r" (CR) does represent the ENTER key. However, if ENTER key means something special to your device, then you would normally use SendKeys(), except, unfortunately, as shown in SecureCRT's Help file, SendKeys() is not supported in Python:

Quote:
Python
Syntax
SendKeys is not currently supported for Python.
I have added this thread to a feature request in our product enhancement database for support for SendKeys() in Python. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #12491" in the subject line or use this form from the support page of our website.

Are you using SecureCRT/Windows and just choosing Python because it's more flexible?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 10-11-2016, 06:31 PM
jakjok jakjok is offline
Registered User
 
Join Date: Sep 2016
Posts: 3
yup, python is more easy for me

also, i'm facing another issue now, and need your advice:


Quote:
outPut = crt.Screen.WaitForStrings ([ "error", ">", "#"], 1000)
index = crt.Screen.MatchIndex
crt.Screen.Send("!" + str(index) + "\r")

if (index == 2):
crt.Screen.Send("!" + str(index) + "\r")
crt.Screen.Send("en" + "\r")
pass

the index value should be 2 when we are on prompt mode while it shows me 3

Quote:
SW2>
SW2>
SW2>!3
SW2>
SW2>
if i removed "#" from the list it works fine , can you help me on this as well
Reply With Quote
  #4  
Old 10-12-2016, 09:32 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,015
Hi jakjok,

Have you set synchronous to True in your script?

This seems like a classic case of the script being out of sync.

Can you post the entire script (redacting sensitive data)?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Tags
keystorke , python , securecrt , telnet


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:09 AM.