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 12-05-2007, 09:34 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
Status Line for script

Hi,

I often write scripts that can run for hours or days in a test environment and it is very useful to be able to provide feedback to the user as to what the script is currently doing.

Previously, with ProComm, I could use a Statmsg command and it would display the message on Procomm's status line. Does SecureCRT have anything like this or does anyone have an example of a dialog that could be updated as the script runs?

Thanks,

Wes
Reply With Quote
  #2  
Old 12-05-2007, 10:43 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Hello Wes,

I can see how it would be very helpful to keep the user informed about what a script is doing by writing information to a status bar. Currently SecureCRT does not provide this option but I've added your forum post to our request database and we'll post a follow up message to this forum thread if we add this capability in a future version. If implemented and you would like direct email notification, please let me know.

However, as a workaround you might consider using the Microsoft Agent. It will allow you to display data and will not interrupt your script. We posted an example SecureCRT script showing how to use Microsoft Agent a while back. You can find the MicrosoftAgentExample SecureCRT script in this link.

Do you think the Microsoft Agent will help you for now?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #3  
Old 12-05-2007, 11:03 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
Yes, I think I will be able to use the MSAgent,

Thanks,

Wes
Reply With Quote
  #4  
Old 12-05-2007, 12:07 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Sounds good. Let us know if you have any quesitons, or any code you'd like to share.
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #5  
Old 12-05-2007, 12:27 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
No Problem. As far as the MSAgent code, all I did was strip out some of the extraneous code and changed the function to Statmsg. That way it's the same as what I used to using.

Here is what I ended up with:

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

' Implements the "StatMsg" comand and uses MSAgent
' for non-intrusive progress/status reporting...

Dim g_fso
Set g_fso = CreateObject("Scripting.FilesystemObject")
Dim g_objAgentControl, g_objAgent, g_AgentReq

InitAgent
ShowAgent

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Main()

crt.screen.synchronous = true

Statmsg "Script running..."
crt.sleep 5000

Statmsg "5 seconds is up"
crt.sleep 5000

End Sub





'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~ MSAgent Status Display Code ~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function Statmsg(szText)
g_objAgent.Stop
ShowAgent
g_objAgent.Think szText
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function InitAgent()
' MsgBox "InitAgent"

Set g_objAgentControl = CreateObject("Agent.Control.2")
g_objAgentControl.Connected = True

Dim objFolder, szCharacters, objFile
Set objFolder = g_fso.GetFolder("C:\Windows\msagent\chars")
szCharacters = "Characters available are:" & vbcrlf
For each objFile in objFolder.Files
szCharacters = szCharacters & g_fso.GetBaseName(objFile.Path) & vbcrlf
Next
Set objFolder = Nothing

Dim szChar
szCharacters = lcase(szCharacters)
if Instr(szCharacters, "merlin") > 0 then
szChar = "merlin"
elseIf Instr(szCharacters, "peedy") > 0 then
szChar = "peedy"
elseif Instr(szCharacters, "genius") > 0 then
szChar = "genius"
elseif Instr(szCharacters, "al") > 0 then
szChar = "al"

' "robby"
' "spaceman"
' "sharky"
' "max"
' "g_objAgent"
end if

Set g_AgentReq = g_objAgentControl.Characters.Load(szChar, "c:\windows\msagent\chars\" & szChar & ".acs")
Set g_objAgent = g_objAgentControl.Characters.Character(szChar)

Dim nLines, nColumns
nLines = 5
nColumns = 80
g_objAgent.Balloon.Style = (g_objAgent.Balloon.Style AND &H00000000) + (nLines*(2^24) + nColumns*(2^16))
g_objAgent.Commands.Caption = "Custom Commands"

' Name, Caption, Voice Command, Enabled, Visible
g_objAgent.Commands.Add "speak", "&Speak...", "speak", True, True
g_objAgent.Commands.Add "exit", "E&xit", "exit", True, True

end function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ShowAgent()
if Not g_objAgent.Visible then
g_objAgent.MoveTo 400, 500, 25
g_objAgent.Show
Do
' Debug 6, "Agent status = " & g_AgentReq.Status
Crt.Sleep 100
Loop While g_AgentReq.Status <> 0
end if
End Function

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function HideAgent()
g_objAgent.Hide
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reply With Quote
  #6  
Old 06-16-2008, 04:28 PM
jtymann jtymann is offline
Registered User
 
Join Date: Jun 2008
Posts: 11
Is this still the method recommended by VanDyke for displaying script status such as "Waiting for xyz". I've been considering using the tab caption, but it seems there should be a better way - like a "Script Status Bar" that you could select and post a message right next to the application status bar.


Quote:
Originally Posted by miked
Hello Wes,

I can see how it would be very helpful to keep the user informed about what a script is doing by writing information to a status bar. Currently SecureCRT does not provide this option but I've added your forum post to our request database and we'll post a follow up message to this forum thread if we add this capability in a future version. If implemented and you would like direct email notification, please let me know.

However, as a workaround you might consider using the Microsoft Agent. It will allow you to display data and will not interrupt your script. We posted an example SecureCRT script showing how to use Microsoft Agent a while back. You can find the MicrosoftAgentExample SecureCRT script in this link.

Do you think the Microsoft Agent will help you for now?
Reply With Quote
  #7  
Old 06-16-2008, 04:54 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
hi jtymann,

The ability to write to the (or a) status bar with a script is not yet available in SecureCRT. As mentioned previously, we will post here should this be implemented in a future release.

In the meantime, the workaround suggested by using MS Agent would probably be the best way to accomplish this.
Reply With Quote
  #8  
Old 06-17-2008, 06:06 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
This is timely. Just yesterday I was considering using the tab caption, but haven't figured out how to do it yet, though I haven't spent too much time trying to. Does anyone have an example I could use until there is a status line capability?

Thanks,

Wes
Reply With Quote
  #9  
Old 06-17-2008, 07:42 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi WesR,

I am not sure I understand exactly what it is you are asking.

Previously you mentioned that you were able to get MS Agent to work. Has this method begun failing?

If so, how is it failing?

Could you clarify more on what exactly it is you are looking for an example of?
Reply With Quote
  #10  
Old 06-17-2008, 08:45 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
No, it's not failing and it was a good workaround for that script that I gave to an admin to run, but a simple indication of what the script is currently doing would be useful in many cases, especially when debugging.

I often don't want a pop-up, but just a way to let me know how many times it has run through a loop or is running and waiting where it should be.

With ProComm, I would use the statmsg command which would indicate in the status line whatever I wanted. I was thinking if I could update the tab caption in a similar fashion. It would be better solution for me than the MSAgent option. A status line option would be better yet.

Of course a follow-on request to this will be is there any way to remove what is currently being displayed in the status line (the connection type, cursor position, size, term type, etc).

Wes
Reply With Quote
  #11  
Old 06-17-2008, 09:18 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi WesR,

I have deleted my last post as the example script I provided was outdated. Attached to this reply is an updated version of the script. I apologize for any confusion.

Is this script helpful?

Regarding clearing the status bar, the only editing of the status bar the can be accomplished is the help comment that appears when the mouse pointer is hovering over a button. This is edited in the menu .mnu file that SecureCRT is using.

I would like to submit a feature request regarding the ability to specify a blank status bar from a .mnu file, if this would accurately capture your request.

Is this what you were looking for?
Attached Files
File Type: txt RenameTabsUponConnect.vbs.txt (739 Bytes, 286 views)
Reply With Quote
  #12  
Old 06-17-2008, 09:40 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
Thanks.

Unfortunately, just scanning through the comments, this example won't work for me because of the required focus and no key presses.

I would want the script to be able to run in the background for long periods of time while I do other things and then allow me to be able to look at the window to see how it is doing or how many times it has run depending on the script. Is there another way to update the caption?

Specifying a blank status bar from a .mnu file might work, but ideally it would be useful to have it under script control. Maybe this does accomplish this, but I'm not sure.

It would be useful to be able to clear the status bar and use it to display a changeable script defined status' and then have the status bar restored when the script finishes. That way my scripts would only change the user's environment while it was running.

Often, there would be enough space where the 'Ready' status is displayed, but sometimes it would be nice to have more by clearing the bar. For example on one of my old scripts it had a status line like this:


connected to router wwww - running test xxx - iteration aa - passed yy - failed zz

Does this make sense?

Wes
Reply With Quote
  #13  
Old 06-17-2008, 11:15 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi WesR,

Regarding the example script, the line in the example script that I think would be most helpful to you would be the following:

Code:
objTab.Caption = szNewTabName

This demonstrates the setting of a tab caption to whatever you want it to be. A line similar to this could be called each time the script ran through a loop, and reflect whatever it is you are looking to have displayed. This would not require focus or key presses.

Using this information, are you able to adapt the line referenced above to fit your needs?

If not, could you post your script, with an exact description of what it is you are trying to accomplish?
When setting the tab caption with the status of the script, the small amount of space available for a tab caption would need to be taken into account.
Regarding the status bar question, it seems like the feature request to set the status bar message with a script is what you would need. As mentioned previously, we will post here should this feature become available in a future release of SecureCRT.
Reply With Quote
  #14  
Old 06-17-2008, 12:02 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
I'm guessing your right about the one line, but I don't see this line in the example and I can't seem to make it work. I really am not very good and scripting and don't really understand how to use this. If I just use:

objTab.Caption = "test"

I get an error stating: Object Required 'objTab'

I'm guessing I need to define objTab to something, but I don't know what.

Wes
Reply With Quote
  #15  
Old 06-17-2008, 12:57 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi WesR,

I am not sure how your script works, so it's hard to explain exactly what it is you need to do, but here is a generic example of getting a handle on the Tab object.

Code:
Dim objTab

' This will give us a handle to the tab on which the script was launched
Set objTab = crt.GetScriptTab

' Now we can manipulate the tab. For more information see the following chapter
' of the SecureCRT Help:
'
'     ActiveX Scripting/Script Objects Reference/Tab Object

objTab.Caption = "Test"
Is this information helpful?
Reply With Quote
Reply


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 11:10 AM.