cpatte7372
asked on
VBS Script Modification Pt5
Hello Experts,
The following script fails when it gets to the line 'crt.session.log True'. Its being used with an application called SecureCRT and its run on a number of tabs. Basically, the script will work fine on the first tab, but when it gets to another tab I get the error message CRT Scripting Runtime error, and then it says Logging already enabled.
I think its because script doesn't recognise that it should start afresh on a new tab.
I wonder if you could assist?
# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs
Sub Main()
if Not crt.Session.Connected then
szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
if szSession = "" then exit sub
crt.Session.ConnectInTab(" /S " & szSession)
crt.Session.ConnectInTab(" /S " & szSession)
crt.Session.ConnectInTab(" /S " & szSession)
end if
arrCommands = Array("end", "term len 0")
' Send commands to all tabs
' Connect to each tab in order from left to right, issue all commands, and
' then disconnect...
For nIndex = 1 to crt.GetTabCount
Set objCurrentTab = crt.GetTab(nIndex)
objCurrentTab.Activate
If objCurrentTab.Session.Conn ected = True Then
crt.Session.Log True
For Each strCommand In arrCommands
crt.Sleep 500
objCurrentTab.Screen.Send strCommand & vbcr
crt.Sleep 1000
Next
End If
Next
End Sub
Cheers
Carlton
scripterror.jpg
The following script fails when it gets to the line 'crt.session.log True'. Its being used with an application called SecureCRT and its run on a number of tabs. Basically, the script will work fine on the first tab, but when it gets to another tab I get the error message CRT Scripting Runtime error, and then it says Logging already enabled.
I think its because script doesn't recognise that it should start afresh on a new tab.
I wonder if you could assist?
# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs
Sub Main()
if Not crt.Session.Connected then
szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
if szSession = "" then exit sub
crt.Session.ConnectInTab("
crt.Session.ConnectInTab("
crt.Session.ConnectInTab("
end if
arrCommands = Array("end", "term len 0")
' Send commands to all tabs
' Connect to each tab in order from left to right, issue all commands, and
' then disconnect...
For nIndex = 1 to crt.GetTabCount
Set objCurrentTab = crt.GetTab(nIndex)
objCurrentTab.Activate
If objCurrentTab.Session.Conn
crt.Session.Log True
For Each strCommand In arrCommands
crt.Sleep 500
objCurrentTab.Screen.Send strCommand & vbcr
crt.Sleep 1000
Next
End If
Next
End Sub
Cheers
Carlton
scripterror.jpg
ASKER
Rob, thanks for responding, going to check it out now...
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Rob,
Thanks again for responding. I will check it out shortly and let you know.
Cheers
Carlton
Thanks again for responding. I will check it out shortly and let you know.
Cheers
Carlton
ASKER
Hi Rob,
Unfortunately, the script now only works on the firs tab, or should I say, 'it only works once', but doesn't work on other tabs. However, at least its not crashing this time.
I think we could be nearly there.....
Unfortunately, the script now only works on the firs tab, or should I say, 'it only works once', but doesn't work on other tabs. However, at least its not crashing this time.
I think we could be nearly there.....
ASKER
Got it working cheers...
Thanks for the grade. Would you mind explaining what you did to get it working?
Thanks,
Rob.
Thanks,
Rob.
ASKER
Hi Rob,
If it's ok I will show you tomorrow - about to hit the sack.
Cheers
If it's ok I will show you tomorrow - about to hit the sack.
Cheers
Yeah, no problem. No rush. It just helps others that may be having the same problem.
Rob.
Rob.
crt.Session.Log True
to this
If crt.Session.Log = False Then crt.Session.Log True
Rob.