chrisayres11 has asked for the wisdom of the Perl Monks concerning the following question:

Banging my head against the wall time

I have a PERL script that runs fine when I manually start it in a Mintty emulator window, but I want it to run from a Windows Scheduled Task

Manually in Minnty I start the script with

perl inventory.pl

My scheduled task action is

D:\cygwin\bin\mintty.exe d:/perl_scripts/Inventory.pl

But this comes back with the error

Can't exec "date": No such file or directory at d:/perl_scripts/inventory.pl line 71.

The rest of the script seems to run fine. Line 71 of the code is

my $date=`date +%d%m%Y`;

why is this one line causing me problems

Replies are listed 'Best First'.
Re: CYGWIN Perl and Mintty
by roboticus (Chancellor) on Jun 13, 2014 at 15:08 UTC

    chrisayres11:

    I expect that it's because the path isn't set up the same as when you're in the shell. You could try specifying the full path, but it may still break if it can't find the DLLs.

    So I'd try either changing your code to remove the dependency on date (localtime and sprintf, for example) or make sure you set up the paths in your task.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: CYGWIN Perl and Mintty
by salva (Canon) on Jun 13, 2014 at 15:14 UTC
    Probably the value of the environment variable %PATH% is different. This is a common problem when running scripts from schedulers.

    In any case you don't need to call an external program to get the date, perl provides the localtime builtin that returns the required information to build that date string yourself.

Re: CYGWIN Perl and Mintty
by Anonymous Monk on Jun 13, 2014 at 15:11 UTC
Re: CYGWIN Perl and Mintty
by chrisayres11 (Novice) on Jun 14, 2014 at 16:58 UTC

    Thanks for all your replies "localtime" has sorted me out. All working fine now :-)