#1
|
|||
|
|||
Launching to Web Interfaces
Trying to make my job a bit faster. When I open a command line of the device I want to open the Website interface of it as well. Here is what I have now. I'm not sure what I'm missing.
Also I want to have one script and just change the arguments within the properties of the devices to the specific IP. # $language = "VBScript" # $interface = "1.0" ' Run.vbs demonstrates how to utilize the Windows Scripting Host (WSH) by using ' its 'Run' method to execute other programs. Note the use of nested quotes to pass ' a path that contains spaces along with command line arguments. Sub Main Dim shell Dim IP Set shell = CreateObject("WScript.Shell") shell.Run """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" https://&IP&:4434" End Sub |
#2
|
|||
|
|||
Hi GuitarDude,
You can get the IP address of the connected session using the RemoteAddress property of the Session object from SecureCRT's scripting API. For Example: Code:
# $language = "VBScript" # $interface = "1.0" strRemoteAddress = crt.Session.RemoteAddress Set shell = CreateObject("WScript.Shell") shell.Run("http://" & strRemoteAddress) For more information about SecureCRT's scripting API please refer to the Help.
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
![]() Quote:
This does work for me. Thanks for the help. I did change a few things like https and adding the port number. |
#4
|
|||
|
|||
Hi GuitarDude,
Great! I am glad to hear that you are all set! My apologies for failing to include the port number in the example! Do you run the script every time that you connect to a session? If so, you can configure a logon script to run the script as soon as you connect in Options > Session Options > Connection > Logon Actions. Simply point to the script in the "Login Script" field. If you do not wish to run the script every time that you connect, you can map a button on your Button Bar to run the script as you please. For more information please refer to our YouTube video: https://youtu.be/qp82UWxGB8I
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by berdmann; 03-11-2019 at 12:08 PM. |
#5
|
|||
|
|||
Web Interface Script
Looking into the button bar a little I just thought of another helpful button. It would be pinging the current session. What is the shell run for that.
|
#6
|
|||
|
|||
Hi GuitarDude,
Correct me if I am mistaken, but it sounds like you are trying to ping the remote that you are connected to. Is that correct? Can you tell me more about the problem that you are trying to solve or the goal that you have as it relates to pinging the "current session"?
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
Web Interface Script
The current session, is what I would like to ping. Continuously pinging the address til it is told to stop. ctrl + c is the break to stop a ping for windows. That should be fine.
|
#8
|
|||
|
|||
Hi GuitarDude,
It is not currently possible for SecureCRT to ping a remote. I would like to capture a feature request on your behalf to add this functionality. Can you please elaborate on why or how this feature will improve your experience with SecureCRT? As a work around, you may be able to automate pinging your remote hosts via CMD with a VBScript, perhaps a VBS forum would be a better resource.
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#9
|
|||
|
|||
![]() Quote:
Sorry I meant to say if the system that I am running the SecureCRT send a ping to current session. Sorry if I wasn't clear about that. |
#10
|
|||
|
|||
Hi GuitarDude,
You can run a script in SecureCRT to get the IP address using crt.Session.RemoteAddress and then launch CMD to do the ping. Here is a general example: Code:
strTarget = crt.Session.RemoteAddress Set objShell = CreateObject("WScript.Shell") Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget) strPingResults = LCase(objExec.StdOut.ReadAll) myResponse = msgbox("Ping Results: " & vbcr & vblf & strPingResults) We were not able to find a way to get CMD to display the ping results real time.
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#11
|
|||
|
|||
Hi GuitarDude,
I stumbled upon this example, in which the ping will run continuously in CMD until you press CTRL+C … Code:
' Attempt to set strHost to some common-sense default ' values... first, see if anything is in the clipboard... strHost = crt.Clipboard.Text ' If not, see if anything is selected in the terminal window... If strHost = "" Then strHost = crt.Screen.Selection ' Set up a default command to run. If the button mapped to ' run this script doesn't have any arguments, then this will ' be what is launched... strCmd = "cmd /C ping __HOST__ -t" if crt.Arguments.Count > 0 Then strCmd = crt.Arguments(0) end if Sub Main() ' Prompt the individual for input as to what to use for __HOST__: ' strHost = crt.Dialog.Prompt("Command to run is:" & vbcrlf & vbcrlf & _ ' vbtab & strCmd & vbcrlf & vbcrlf & _ ' "What host would you like to run the command on?", "Command Runner", strHost) ' handle cancel strHost = crt.Session.RemoteAddress if strHost = "" Then Exit Sub ' Replace __HOST__ with what was supplied... strCmd = Replace(strCMD, "__HOST__", strHost) ' Now, run the command and tap into stdout...reading all the data until it exits... Set g_shell = CreateObject("WScript.Shell") ' replace /C with /K to keep CMD window open strCmd = Replace(strCMD, "/C", "/K") g_shell.Run strCmd End Sub
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#12
|
|||
|
|||
Quote:
|
![]() |
Tags |
scripts , website |
Thread Tools | |
Display Modes | Rate This Thread |
|
|