0

I have awstats installed on windows 2008 server. I schedule the Updatestats.bat file to run every day, the task runs fine without error, but the script is not being executed or is throwing an error that I cannot see.

-- If I run the bat file directly from command line then it works fine. --

I have tried various alternatives to the windows scheduler, such as "nncron" and "Freebyte Task Scheduler", nncron had the same issue, but the freebyte app worked, but sadly it does not run as a service so is of no use. here is the contents of the bat file, all lines look like this.

c:\strawberry\perl\bin\perl.exe D:\AWStats\wwwroot\cgi-bin\awstats.pl config=earlsmere.co.uk -update

anyone got any ideas ?

Levon
  • 138,105
  • 33
  • 200
  • 191
snake
  • 732
  • 1
  • 6
  • 11
  • I don't know Perl, so this could be or not an answer, but do you need some data from the current directory? And, if yes, do your Perl script run from the directory where data resides? – Steve Jun 03 '12 at 12:28

2 Answers2

1

Your unattended environment is obviously different from you command line. Check if the following are set:

  1. Script's working directory, if it reads anything from it or uses relative paths.
  2. PERL*_LIB environment variables if your script uses any modules.
  3. PATH environment variable, if your script calls any external scripts/binaries.
  4. User that is running scheduled tasks have sufficient rights for everything you want to do.

As a quick workaround you can set them directly in script using chdir function, lib module, and $ENV{PATH} entry.

You also can try to capture standard output and error with following redirections before you start doing anything else:

open(STDOUT, '>>', '/full/path/to/out.log') || die "Error stdout: $!";
open(STDERR, '>>', '/full/path/to/err.log') || die "Error stderr: $!";

Note that you really should use full paths there in case you indeed have working directory set wrong. And make sure target directory/file is writable for anyone.

Oleg V. Volkov
  • 21,719
  • 4
  • 44
  • 68
0

Looks like the output gets lost in space...

I suggest redirecting the output of the command to a file, like this:

c:\strawberry\perl\bin\perl.exe D:\AWStats\wwwroot\cgi-bin\awstats.pl config=earlsmere.co.uk -update > c:\my_log.txt 2>&1

(courtesy of Anders Lindahl: Redirect stdout and stderr to a single file in DOS)

Community
  • 1
  • 1
Gonen
  • 4,005
  • 1
  • 31
  • 39