#1
|
|||
|
|||
![]()
Good day! I am trying to launch a SecureCRT session from a Microsoft Excel macro, but am running into an issue with regard to the session connecting successfully. It is opening SecureCRT, but then is spitting out an error:
"Hostname lookup failed: host not found" Macro code: Code:
Sub Launch_SecureCRT() ' Enter credentials in custom form Win_Login.Show strPassword = passkey strUsername = username 'host and protocol strProtocol = "ssh2" strHostname = "host.com" ' Reference the SecureCRT script file to be run upon launch Set fso = CreateObject("Scripting.FileSystemObject") strScriptFile = "C:\Users\filepath\script.js" ' Open SecureCRT and run script with login creds. Set objShell = CreateObject("wscript.shell") nResult = objShell.Run( _ "SecureCRT /SCRIPT " & strScriptFile & _ " /arg " & strHostname & _ " /arg " & strUsername & _ " /arg " & strProtocol & _ " /PASSWORD " & strPassword, _ 5, True) End Sub Thank you for your time! |
#2
|
|||
|
|||
Hi mschaafs,
It appears that the format of arguments being sent to the shell may not have been correct. I had luck in launching sessions from an Excel macro using the below code: Code:
Sub Launch_SecureCRT() strScriptFile = "C:\Users\filepath\script.js" strUsername = "username" strHostname = "host.com" strProtocol = "/SSH2" strPassword = "passkey" Call Shell("SecureCRT /SCRIPT " & strScriptFile & _ " " & strProtocol & " /PASSWORD " & strPassword & _ " " & strUsername & "@" & strHostname) End Sub
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
![]()
That did the trick! Thank you so much!
|
#4
|
|||
|
|||
![]()
Ok... Hoping you can help me with one last thing... /ARG, I am trying to pass arguments to my script... and so I added another argument to pass in as:
Code:
' Open SecureCRT and run script with login creds. Set objShell = CreateObject("wscript.shell") nResult = objShell.Run( _ "SecureCRT /SCRIPT " & strScriptFile & _ " " & "/ARG " & strArgToPassIn & _ " " & strProtocol & " /PASSWORD " & strPassword & _ " " & strUsername & "@" & strHostname, 5, True) Code:
var testvar = crt.Arguments[0]; crt.Dialog.MessageBox(testvar, "TESTVAR IS"); |
#5
|
|||
|
|||
Hi mschaafs,
I'm glad to hear that worked for you. Hopefully you have smooth sailing from here on out.
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#6
|
|||
|
|||
Hi mschaafs,
In my testing JavaScript uses the same format at VBScript. Code:
var testvar = crt.Arguments(0); crt.Dialog.MessageBox(testvar, "TESTVAR IS");
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
![]()
Fantastic... that worked. I should have thought to try that. :P Thank you again for your time!
|
#8
|
|||
|
|||
Hi mschaafs,
I'm glad I could help and that you're up and running. Have a great rest of the day.
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
excel to securecrt , hostname , wscript |
Thread Tools | |
Display Modes | Rate This Thread |
|
|