View Full Version : Need Script to initiate new tabbed session
jdurrett
07-20-2005, 12:04 PM
I have been unsuccessfull at performing the following task in scripting:
A. Be in active session. (Successfull)
1. Issue command. (Successfull)
2. Screen Scrap host and port info returned. (Successfull)
3. Launch new tabbed session with /Arg Host /Arg Port /Script login.vbs
Failure - at step 3.
B. Continue work in new session.
All I can determine from the help system, faq's, scripting examples, and forum is that you can disconnect and reconnect within a session, but I have not seen how to do this where a new session is launched using two arguments and a specified script that will act as login script.
albundy
08-01-2005, 02:47 AM
Hello,
what is the code you use to specify you want to connect in a tabbed session ?
There isn't currently an interface for connecting to a session within a new tab in SecureCRT's scripting API.
However, the ability to connect within a newly created tab from within a script is something that we hope to add to SecureCRT version 5.1.
In the meantime jdurrett, you might be able to get close to what you need by following these steps (that don't involve tabs, but instead use separate instances of SecureCRT):
A. Be in active session. (Successfull)
1. Issue command. (Successfull)
2. Screen Scrap host and port info returned. (Successfull)
3. Launch new instance of SecureCRT with /Arg Host /Arg Port /Script login.vbs. For example:
'... after screen-scraping to determine host and port
Set myShell = CreateObject("WScript.Shell")
myShell.Run(chr(34) & "C:\Program Files\SecureCRT\SecureCRT.exe" & chr(34) & _
" /ARG " & szHost & " /ARG " & szPort & _
" /SCRIPT " & chr(34) & "C:\Documents and Settings\user\My Documents\login.vbs" & chr(34), _
5, _
True)
B. Continue work in new session.
(This would be a separate script, "login.vbs".)
'...
szHost = crt.Arguments(0)
szPort = crt.Arguments(1)
crt.Session.Connect "/SSH2 /PORT " & szPort & " " & szHost
'...
--Jake
jdurrett
08-11-2005, 08:11 PM
This is the weirdest thing. I managed to get it working prior to seeing your feedback - using the same methods except the /SCRIPT scriptname.vbs was located before the /ARG statements. Have this working on co-workers machine but it will NOT run on mine.
When run - I put test popup message in it - so I see the command line looks right...but the new CRT instance returns error message "Hostname lookup failed: no IP address associated with hostname."
This is the weirdest thing. I managed to get it working prior to seeing your feedback - using the same methods except the /SCRIPT scriptname.vbs was located before the /ARG statements. Have this working on co-workers machine but it will NOT run on mine.
When run - I put test popup message in it - so I see the command line looks right...but the new CRT instance returns error message "Hostname lookup failed: no IP address associated with hostname."
What is the actual string you are passing (in the new CRT instances's script) to the crt.Session.Connect() method?
If you use the same values as command line arguments when launching CRT from the command line or Start/Run, does it connect successfully?
What are the differences between your machine and the machine of your coworker (with respect to their network connections, where CRT is installed, where the configuration folder is located, etc.)?
--Jake
jdurrett
08-12-2005, 07:23 PM
Note sure of the root cause, however it is now working on my computer after much "playing around" trying different ways to add strings together. I can say that the example above for using Chr(34) was not well received by the system. The objShell.Run(Chr(34)...etc) produced error regarding Subroutines not allowed to be called with Parenthesis ().
I do appreciate this forum greatly and everyones input. Seeing others struggle and succeed is what helps motivate me to never give up. I stilll think despite what complaints I may have on the completeness of documentation that this is the best telnet application out there. I am constantly showing off the automation routines I have put together with this product. My Sr. Manager has recommended that I go thru the process of getting this software approved for bulk purchases by our company. Its a pain of red tape, but well worth it. I have co-workers standing buy. :)
For everyones Benefit - here is the working code. Note Input being scrapped from the screen is:
"zrc2h0mz-40> split_ip
split_ip: target zrc2h0mz.23, listening on zrc2h0mz.49166 for connections"
File1: SPLIT_IP.vbs
# $language = "VBScript"
# $interface = "1.0"
crt.Screen.Synchronous = True
Sub Main
Dim objShell
Dim szCmd, szArgs, szca
crt.Screen.Send "split_ip" & Chr(13)
crt.Screen.WaitForString "split_ip:"
crt.Screen.WaitForString "connections"
screenrow = crt.screen.CurrentRow
readline = crt.Screen.Get(screenrow, 1, screenrow, 80 )
If Len(readline) <> 0 Then
' Split the line ( ":" delimited) and put some fields into Excel
'
items = Split( readline, " ", -1 )
myHost_Port = Split(items(5), ".")
szHost = " /ARG " & myHost_Port(0)
szPort = " /ARG " & myHost_Port(1)
End If
Set objShell = CreateObject("WScript.Shell")
szCmd = """C:\Program Files\SecureCRT\SecureCRT.exe"""
szArgs = " /SCRIPT ./CATCH_SPLIT.vbs "& szHost & szPort
szca = szCmd & szArgs
objShell.Run(""&szca&"")
End Sub
File2 = CATCH_SPLIT.vbs
...
Sub Main
Dim szHost, szPort
If crt.Arguments.Count < 2 then
MsgBox "Usage: " & vblf & vbtab & _
"SecureCRT.exe /Script catch_split.vbs" & _
" /ARG HostIP /ARG Port"
exit sub
end If
' Retrieve the arguments
szHost = crt.arguments(0)
szPort = crt.arguments(1)
crt.Screen.Synchronous = True
'Next line is to show me that the arguments captured are correct
MsgBox szHost&" "&szPort
crt.Session.Connect "/telnet "&szHost &" "&szPort&""
crt.Screen.WaitForString "ogin:"
crt.Screen.Send UnixId & vbCr
crt.Screen.WaitForString "assword:"
...etc
jdurrett
08-30-2005, 12:45 PM
I figured out that the problem I was fighting was some kind of initialization bug.
Case: Script is launched from Menu system, or from recent script listed - (This is the Split_IP.vbs script). Per the script - a new session is launched with the script name being passed by /SCRIPT ./Script.vbs and two arguments.
Now, If the script is identified as "/SCRIPT ./myscript.vbs" then I get a file not found by the new instance of SecureCRT. If the script is identified as "/SCRIPT /C:\ProgramFiles\SecureCRT\scripts\myscript.vbs" then the script is found but now it thinks the script is the session name and says it cant find it - host not found.
Fix: Select Script from Menu, Then RUN - Browse to script and run it manually this way...and the first command ("... /SCRIPT ./myscript.vbs") works. Thereafter, I can run the script from the menu or the recent file list (for scripts) and they work properly.
Why this has to be run manually before the others will work..I dont know..but that is the reality of it.
Would like to see these issues resolved as I butt heads with them over and over and I cannot fix some scripts by running from scratch every time.
Regards.
bocks
08-30-2005, 10:32 PM
Hello jdurrett,Fix: Select Script from Menu, Then RUN - Browse to script and run it manually this way...and the first command ("... /SCRIPT ./myscript.vbs") works. Thereafter, I can run the script from the menu or the recent file list (for scripts) and they work properly.
Why this has to be run manually before the others will work..I dont know..but that is the reality of it.
Would like to see these issues resolved as I butt heads with them over and over and I cannot fix some scripts by running from scratch every time.This does indeed look like a bug in SecureCRT. Can you tell me if you are seeing an error message something like this:---------------------------
SecureCRT
---------------------------
Failed to open script file. error = 3
---------------------------
OK
--------------------------- when you try to run the scripts from the menu directly?
After doing some experimenting, it looks like this bug appears after using the File browser dialog to navigate to another folder or file, say to set the location of a log file. What happens at this point is that SecureCRT is now looking into the new directory location.
In your menus, you are using relative addressing by use of the ./ in the file path to access the scripts. Because the working directory was changed, SecureCRT can not locate the script files. Changing the working directory should not be having this affect.
As of right now, I am aware of two work arounds for this problem. The first is to place the scripts into a known location and then modify the menu to use an absolute path to the files, just as you have discovered.
The second is to make sure that if the File Browser dialog is used, that you browse back to the correct location. By default this would normally be the application installation directory:c:\Program Files\SecureCRTWe have created a bug report for this incident, and will post a notice to this thread when a fix becomes available, but if you would like to e notified privately as well, I will need to get your contact information. Pleae send a message to me at Support@vandyke.com with a subject of Attn: Shannon re: Forums thread 914
I will add your contact information to the contact list for this problem. Once a fix becomes available, we will use this information to notify you of the fix.
Please let me know if this helps clarify the behavior that you are seeing.
Thanks,
-bocks
bocks
09-14-2005, 03:20 PM
Hello jdurrett,
Our developers have been working on this problem and have an updated version that addresses this problem. We would like you to try the updated version of SecureCRT.
In order to provide access to the updated version, I need to get your ontact information. Please send a message to me at Support@vandyke.com with a subject of Attn: Shannon re: Forums thread 914
In the body, please have your contact information. Once I get your message, I can reply back with the instructions on how to download the updated version of SecureCRT.
If any other users are affected by this bug, please follow the instructions above to let me know.
Thank you,
-bocks
jdurrett
10-13-2005, 06:53 PM
I am glad to have the bug confirmed..I have emailed my contact information seperatly. I just wanted to note here that I have posted an article of sorts for my menu automation scripts in the scripting section. Getting my scripts created was an accomplishment for myself...putting full paths for everything would be very challenging...that and I plan to share my scripts with my co-workers where possible and cannot depend upon them having the same directory structure or locations so I need my scripts to be as drive and path independant as possible.
Cheers.
Maureen
06-30-2006, 06:10 PM
Scripting support for tabs has been implemented and is available in a pre-beta version of SecureCRT 5.2. If you're interested in trying it, please send an e-mail to me at Maureen.Jett@vandyke.com.
Maureen
Is there any chance to get it in verion 4.x?
Maureen
07-27-2007, 09:19 AM
Is there any chance to get it in verion 4.x?For a number of reasons, we don't backport features. Is there a reason you're not able to upgrade to the latest version?
Maureen
vBulletin v3.5.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.