New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Custom Batch Script fails to run Find command

Votes:

0

Your Vote:

Up

Down

I have a custom script sensor that runs a simple batch file that looks inside a txt file and then checks errorlevel variable for 0, 1, or 2+.

this script runs perfectly fine when executed from the command line on the machine.

PRTG though when running it, shows that it simply isn't running the "Find" command at all, but its not treating it like a bad command.

Here's the output I'm seeing that illustrates the problem:

  1. Here I run di as an incorrect command, and I get this error so I know its not a problem that PRTG doesn't see the Find command.

C:\XxXxXxXx\Scripts\backup\logs>di 'di' is not recognized as an internal or external command, operable program or batch file.

C:\XxXxXxXx\Scripts\backup\logs>echo.%errorlevel% 9009

  1. Here is the find command, set to ignore case and find the word Error in the log file in that directory. C:\XxXxXxXx\Scripts\backup\logs>find /I "Error" test.log
  1. This error level is for when it doesn't find anything, but there's no output from Find which isn't normal, you can see normal output from Find below. C:\XxXxXxXx\Scripts\backup\logs>echo.%errorlevel% 1

Below is the same command, run from the command line of the machine.

C:\XxXxXxXx\Scripts\backup\logs>find /I "Error" test.log

  1. This TEST.LOG line should be showing if the command is able run at all.

---------- TEST.LOG This is a perfectly good Error backup log.

I have other commands all referencing this file in the same script, and all are finding it. It is only the FIND commands that are exhibiting this odd behavior of no output, error code to 1.

I've given the script the full path to the file, and tested that the DIR command before the FIND was in the right directory, so I know it can see the file.

Any help would be appreciated.

batch find script

Created on Sep 9, 2011 12:04:06 AM by  velmeran (10) 1



2 Replies

Votes:

0

Your Vote:

Up

Down

Hello,

please check if it makes any difference if the PRTG Probe Service runs under your account (or an admin account) just like when you execute the script yourself. Furthermore, please be aware that it might be necessary to specifically define the paths in scripts used by PRTG, do not use relative paths. And please also be aware that the Custom Script sensors have an option in their "Settings" to write their last result as a log onto the harddrive.

best regards.

Created on Sep 9, 2011 2:26:03 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

After some trial an error I've found that for what ever reason, PRTG or the system wouldn't run the FIND command correctly, but when I switched to FINDSTR I was able to get the script working again with correct output.

The original script still works fine with FIND when run from a command prompt, and works with FINDSTR too, it was simply when being run from PRTG probe that it proved unusable.

One caveat would be that if I used a FOR loop to run the find command, it would run, but always report the file wasn't found even with full path given, and because I'm just checking errorlevel output, not usable as I'd only be able to check the errorlevel of the FOR command.

For reference, this was on a SBS2003 server and using just a simple batch file script.

Created on Sep 12, 2011 3:34:42 PM by  velmeran (10) 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.