Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Script Mysteriously Quits

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,57723
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script Mysteriously Quits
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Script Mysteriously Quits - 3/10/2008 5:51:27 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
This script sends a single ping to a remote host and logs the time and result into a CSV file

Can anyone tell me why it will only do 1721 iterations and then stop?

FIXED - UPDATED THIS CODE WITH FIXES SUGGESTED IN FORUM - Thanks Guys


      

< Message edited by TomRiddle -- 3/12/2008 4:45:00 PM >
 
 
Post #: 1
 
 RE: Script Mysteriously Quits - 3/10/2008 8:23:40 PM   
  ginolard


Posts: 1051
Score: 21
Joined: 8/10/2005
Status: offline
Probably because of this line?

if strRemoteIP ="" then wscript.quit

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to TomRiddle)
 
 
Post #: 2
 
 RE: Script Mysteriously Quits - 3/10/2008 10:04:36 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
Hi ginolard,

Nope, that is not it :)

I am thinking of rewriting it from scratch and doing a few things a lot better, which will probably fix it but it supposed to be just a quick knock up script for a job.

Thought I would throw it out there and spend a little more time debugging first, though I cant see any evidence of a bug except the fact that it stops logging after iteration 1721.

That is a 45kb file and ~30mins run time.

(in reply to ginolard)
 
 
Post #: 3
 
 RE: Script Mysteriously Quits - 3/10/2008 10:21:32 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
Out of memory on this line:- sTempFile = objFSO.GetSpecialFolder(2).ShortPath & "\" & objFSO.GetTempName

I can sort that, thanks anyway.

(in reply to ginolard)
 
 
Post #: 4
 
 RE: Script Mysteriously Quits - 3/10/2008 11:43:08 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
This seems a lot better if anyone is interested, I like the way it pipes the output to the cmd window and a log file.
I will run it over night to make sure though.


      

(in reply to TomRiddle)
 
 
Post #: 5
 
 RE: Script Mysteriously Quits - 3/11/2008 10:05:22 AM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
OK it is still officially a mystery.

It does 1720 iterations and bombs out

C:\Documents and Settings\user\Desktop\PingLogger.vbs(92, 1) Microsoft VBScript runtime error: Out of memory: 'objFSO.FileExists'

Can anyone give me any hints as to what I am doing wrong?

(in reply to TomRiddle)
 
 
Post #: 6
 
 RE: Script Mysteriously Quits - 3/11/2008 11:11:57 AM   
  TNO


Posts: 1247
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Put Option Explicit at the top of the script. You have at least 2 undefined variables. This may plug your memory leak.

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to TomRiddle)
 
 
Post #: 7
 
 RE: Script Mysteriously Quits - 3/11/2008 11:16:29 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
My first suggestion....if you're running this on WinXP or better....use WMI to ping the ip/host name and get the reply time. (it will be cleaner)

In your WriteLogFile Sub you have this variable ScriptPath that isn't being used; you've also defined objFSO at a global level so you don't need it in the sub...

I'm not sure what the purpose of this is (see below) since shortly after you open the file for appending and designate create (True)

      

As it is, you could simply have your WriteLogFile be


      

Why not just have the script do a quick check, log, and then end?  If you want it to periodically check....then set it as a scheduled task.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TomRiddle)
 
 
Post #: 8
 
 RE: Script Mysteriously Quits - 3/11/2008 10:49:14 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
Thanks for your help Guys,

That's some really good advice, I guess all those bugs really shows that I threw it together, oh well... it sort of works, except for this memory bug that I have never come across. the most infuriating thing about it is that I have to run it for 30 mins before the bug happens.

I tried the option explicit (it was not that)
I fixed up the scriptpath variable (it was not that)
I got rid of the objFSO that I had already defined at the global level (it was not that)
I replaced the WriteLogFile sub with the elegant one that you wrote dm_4ever (it was not that)

I still get a memory error, but now :-
C:\Documents and Settings\user\Desktop\PingLogger.vbs(101, 3) Microsoft VBScript runtime error: Out of memory: 'objFSO.OpenTextFile'

I'd rather not have to change the ping to WMI version in case I want to ping a router, but it is an excellent idea that I will try tomorrow.

And thanks dm for the other excellent idea of using scheduled tasks to do a periodic check. That definitely will get around this problem but it has now got to the stage where I need to work out why it is bombing out, for my own sanity, there is nothing special about this script.

I have updated the first post with my latest version of this script, which still bombs out.

(in reply to dm_4ever)
 
 
Post #: 9
 
 RE: Script Mysteriously Quits - 3/11/2008 11:21:34 PM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
The Function PingResult(strHost) is doing an endless recursion and never exiting.
Remove the line[ PingResult strHost ] from the bottom of the Function and put it in a loop in the mainline routine.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to TomRiddle)
 
 
Post #: 10
 
 RE: Script Mysteriously Quits - 3/12/2008 1:00:58 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Just an FYI, pinging via WMI only require WMI on the machine you're pinging FROM and not the machine you're actually pinging...so a router should be no issue.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TomRiddle)
 
 
Post #: 11
 
 RE: Script Mysteriously Quits - 3/12/2008 1:17:25 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
Thanks Rischip, You fixed it.
and
Thanks dm_forever, I won't update this script with the WMI ping code but will work out how to use that in future scripts like this. I have one in particular that I am working on that reads the output of a ping and returns an IP. I used ping.exe because I thought WMI would not return the ip from a device which does not have WMI installed. Maybe WMI ping does.

I updated the original post with the fixed version.

(in reply to Rischip)
 
 
Post #: 12
 
 RE: Script Mysteriously Quits - 3/16/2008 10:54:17 PM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
You're welcome. Very easy mistake to make. One I'm sure you won't make again. Always remember with recursion you need a control to somehow verify that the loop is not infinite. 

_____________________________

Rischip
Author of - The Grim Linker

(in reply to TomRiddle)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script Mysteriously Quits Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts