Timeout causes script to terminate (General questions)
I just bought wodssh activex.
I am struggling with on error resume next in windows 2000 and .vbs vb script. I have a loop in sql and am doing a task for each record, however when processing one record and wodssh hits the global timeout the entire script terminates instead of moving to the next record, even though I have on error resume next. Any ideas?
Sub getstorelist()
'Connect to SQL on CAWUPMON and get list of current stores to pass to checkmodem function
Set objADOConna = CreateObject( ADODB.Connection )
Set objRSa = CreateObject( ADODB.Recordset )
objSQLConna = Provider=SQLOLEDB; Data Source = cawupmon; Initial Catalog = WhatsUp; User Id = readonly; Password = readonly;
objADOConna.Open objSQLConna
set objRSa = objADOConna.Execute ( SELECT left(sDisplayName, 4) AS storeNums from device where (nActionPolicyID = 4358 or nActionPolicyID = 4837 or nActionPolicyID = 5053) ORDER BY sDisplayName )
Do While Not objRSa.EOF
router = objRSa( storeNums )
tasklist()
objRSa.MoveNext
Loop
objRSa.Close
objADOConna.Close
Set objRSa = Nothing
Set objADOConna = Nothing
WScript.Quit 1
End Sub
if err.number <> 0 then
wscript.echo *********************
wscript.echo ERRORS FOUND
wscript.echo & err.number
wscript.echo & err.description
wscript.echo & err.source
wscript.echo *********************
GetCurrentTime = Now
Set objFSO = CreateObject( Scripting.FileSystemObject )
Set objTextFile = objFSO.OpenTextFile( c:scriptscheckmodemscripterrors.csv , 8, True)
objTextFile.WriteLine(GetCurrentTime & , & router & , & err.number)
objTextFile.WriteLine(GetCurrentTime & , & router & , & err.description)
objTextFile.WriteLine(GetCurrentTime & , & router & , & err.source)
objTextFile.Close
err.clear
errorcheck = 1
end if
Re: Timeout causes script to terminate
Hi Logan,
I can't really help because I don't see wodSSH code. Can you explain why you are receving timeout error?
You can change wodSSH Timeout Property to 0 and wodSSH will not auto disconnect from server. Also you can call Disconnect Method if you want to disconnect from server when task is finished.
More help for Timeout Property you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~Timeout.html
Let us know how it goes.
Regards,
Drazen
Re: Timeout causes script to terminate
Thanks for your reply.
Here is the code where it hangs. I could change the timeout to 0 but I have a feeling the script will never find the text in the wait for. The second line from the bottom is the one where the code is exiting... I am reverse telnetting into a modem on a router and it is proving to be very tricky, as not all of the modems are responding or echoing (dipswitches are not all proper) ... I if I wait for a LF it works a little bit more often, but the way I've got it now waiting for any character A-Z works very well, except those cases where the modem freaks out and doesn't send anything back. Is there a way to make it so the script does not break on all errors, or is there a way to make wodssh dll not exit the script when it hits the timeout? Or if you've got any ideas for my script.
CRLF = Chr(13) & Chr(10)
CR = Chr(13)
LF = Chr(10)
Set ssh = CreateObject( WeOnlyDo.wodSSHCom.1 )
ssh.HostName = routerip
ssh.Login = username
ssh.Password = password
ssh.Blocking = true
ssh.Protocol = 4
ssh.Timeout = 65
ssh.Connect
''... blah blah login and do other stuff ...
ssh.Send atdt & phonenumber & CRLF
wscript.echo dialing & phonenumber
ssh.WaitFor regex:[A-Z]
sSocketText = ssh.Peek + sSocketText
''... blah blah do more stuff ...
Re: Timeout causes script to terminate
Logan,
I don't see where you use On Error Resume Next . Is there any chance we could perhaps connect there any duplicate the issue?
Also, Could you try using WaitFor before Send? (right after connect)
Another thing you can try is setting Timeout parameter in your WaitFor call. WaitFor method accepts timeout value as second parameter. Does that help?
Regards,
Damba
Re: Timeout causes script to terminate
On error resume next is at the top of the script and the sub routine.
Is there any chance we could perhaps connect there any duplicate the issue?<<
I might be able to arrange that but want to keep trying some of these ideas first.
There are several waitfor's before the send as well as other sends... the script is long and don't want to put it all there. It is definately exiting on the wait for I talk about here.
I've also set the timeout after the waitfor command, but regardless there or the global, I get this error:
1460
The current connection has timeout.
WeOnlyDo.wodSSHCom.1
My router will also disconnect the session after 5 minutes of inactivity, I am experimenting with the timeout 0 option, but do you have any other ideas?
Re: Timeout causes script to terminate
With a global (or waitfor) timeout of 0 the router actually disconnects the session forcefully after 5 minutes of no activity.
10053
The current connection has been aborted by the network or intermediate services.
WeOnlyDo.wodSSHCom.1
This is a challenge because I have 800 modems attached to 800 routers to go through but not all of them behave exactly the same...
Re: Timeout causes script to terminate
When I wait for a line feed I get through more stores, but still there are some situations where the network connection is reset... however in these situations I still need to proceed with my script and try the next router from my SQL.
10054
The current socket connection has been reset.
WeOnlyDo.wodSSHCom.1
It's basically ignoring my 'on error resume next'
I'm stumped at this point.
Re: Timeout causes script to terminate
Logan,
Do you perhaps have any firewalls active? If so, can you please disable them and try it out?
Also, you can try setting KeepAlives property to some value. This should prevent server disconnection.
If all of this fails, then I', affraid we will need access to your network to connect and duplicate on our side.
One more note. Are you using the latest version? If not, I would strongly suggest that you download and try it out.
Regards,
Damba
Re: Timeout causes script to terminate
Can you ping me with your contact info, my email addy is lstonebr@yahoo.com. I will send you the login information so you can reproduce the problem. I will also try the keepalive option. Yes there are numerous firewalls in play that I cannot disable, however for this tunnelled ipsec traffic the firewalls are merely router based access lists, not actual firewalls doing stateful inspection.
Re: Timeout causes script to terminate
and yes, latest version downloaded yesterday when I bought it...
Re: Timeout causes script to terminate
LOL, with the keepalives enabled now the connection stays alive and the router does not disconnect per the vty timeout, but unfortunately the modem will never send a line feed, so the waitfor event will wait forever. (or unless the connection drops from outside input, which could be weeks, months, even years).
Re: Timeout causes script to terminate
Logan,
You can send your private information to: techsupport@weonlydo.com
including informations how to connect to your server.
Drazen