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 05-03-2019, 03:49 AM
vikram1840 vikram1840 is offline
Registered User
 
Join Date: May 2019
Posts: 13
VBS Script showing error

Hello Experts,
I am using securecrt8.5 and want to connect session through VBS script.
In general while connecting the session manually it ask about username,pswd and neId as well and after putting all info it get connect. But the same while i am doing through VBS script it showing error of connection failed.

Point to note-required server is having port other than 22 and apart from it required neId as well. so pleas guide me to run this script succfully.


Code:
# $language = "VBScript"
# $interface = "1.0"

  Sub Main

    Dim pass
    Dim session_name
    Dim password
    Dim user_name
    Dim log_file

    Hostname = "100.100.10.10"
    user_name = "usernm"
    password = "pswd"
    neId = "ABCD-GHIJK-LMNP"
    log_file = "C:\Users\vikramku\Desktop\OSS Connect Macro\Logs\logs.txt"

    crt.Session.LogFileName = log_file
    crt.Session.Log True

    cmd = "/SSH2 /P 8022 /L " & user_name & "/PASSWORD " & password & "/neId" & neId &  " /C 3DES /M MD5 " & Hostname 
    crt.Session.Connect cmd

    crt.Screen.send "amos ABCD" & vbCr
    login = crt.Screen.WaitForStrings(">", "Not OK")
    If login = 2 Then
      MsgBox "Information : ABCD is not Reachable, Please click ok to continue.", vbExclamation
    Else
      crt.Screen.send "lt all" & vbCr
      crt.Screen.send "st cell" & vbCr
      crt.screen.send "exit" & vbCr
      crt.Screen.WaitForString "Bye..."
    End if

    crt.screen.send "exit" & vbCr
    crt.screen.synchronous = false
    crt.Screen.WaitForString "logout"

    crt.Session.Log False
    crt.Session.Disconnect
    crt.Quit

  End Sub

Last edited by jdev; 05-03-2019 at 09:36 AM.
Reply With Quote
  #2  
Old 05-03-2019, 10:03 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 931
Dear vikram1840,

Please use [CODE] and [/CODE] tags around your script code so that indentation/formatting is not lost through HTML browser space aggregation; for example:
With respect to the code you're writing and the error that occurs, what is the exact wording of the error/failure message(s) that you see?

To display debugging/troubleshooting info for connection attempts, you can set Trace Level to 1 for such info to be displayed to the terminal window before you make the call to Connect().

Also, unless your user_name variable's value includes a trailing space character, you're ending up with the /PASSWORD component immediately concatenated to the end of your username, which could be a source of problems for you (see the first section of your code marked in red below). Imagine this working?
SecureCRT /SSH2 /L usernm/Password p4$$w0rd/neIdblahblahblah 100.100.10.10
No. That won't work... it will start the auth process as user "usernm/Password" and all the rest of the command line will be gibberish because SecureCRT can only then assume that p4$$w0rd/neIDblahblahblah is the host name.

In addition, I have to question... why are you limiting the connection to only being able to use the deprecated/old 3DES cipher and MD5 MAC? (see the second section of your code marked in red below). If you're connecting to any newer hosts, that cipher and/or MAC may not be supported. I'd suggest eliminating this from your code unless you somehow want to the connection to fail or use the weakest of all algorithms.

Code:
    .
    .
    .
    crt.Session.LogFileName = log_file
    crt.Session.Log True

    ' Turn on Trace Options before attempting the connection
    ' so that troubleshooting/debugging info can be displayed
    ' to the terminal screen:
    crt.Session.Config.SetOption "Trace Level", 1

    cmd = "/SSH2 /P 8022 /L " & user_name & "/PASSWORD " & password & "/neId" & neId &  " /C 3DES /M MD5 " & Hostname 
    crt.Session.Connect cmd

    crt.Screen.send "amos ABCD" & vbCr
    .
    .
    .

--Jake
Attached Images
File Type: png Forum_Post_WrapCodeWith[CODE]Tags.png (46.7 KB, 182 views)
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 05-10-2019, 01:00 AM
vikram1840 vikram1840 is offline
Registered User
 
Join Date: May 2019
Posts: 13
VBS Script showing error

Hello JDev,

Thanks for your reply.
I have got solution.
Issue was with this part deprecated/old 3DES cipher and MD5 MAC.
When I was considering this part in my code it selected only 3DES in ciper and MD5 in MAC while new host was not supporting other ciper and MAC so it reflected error.

Now I remove this part and code works.

Code:
crt.Session.LogFileName = log_file
    crt.Session.Log True
	crt.Session.Config.SetOption "Trace Level", 1

   cmd = "/SSH2 /L " & session_name & " /PASSWORD " & password & " " & pass
    crt.Session.Connect cmd
Reply With Quote
  #4  
Old 05-10-2019, 09:05 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 931
Quote:
Originally Posted by vikram1840 View Post
...new host was not supporting other ciper and MAC so it reflected error. Now I remove this part and code works.

Code:
crt.Session.LogFileName = log_file
    crt.Session.Log True
	crt.Session.Config.SetOption "Trace Level", 1

   cmd = "/SSH2 /L " & session_name & " /PASSWORD " & password & " " & pass
    crt.Session.Connect cmd
Glad to know you have a solution in place now.

Very nice use of [CODE][/CODE] tags!

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply

Tags
neid , port


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 10:32 PM.