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

Hi,
I 've writen a script and it runs good with parameters in Dos (ENV:win2k+ Activeperl 5.8)
Then i want to use Windows Task Scheduler to run it 12times/day
but it doesn't run any more and reported no @ARGV. so i wrote a test.pl
#! d:\perl\bin\perl.exe -w use strict; print "\nbegin:\n"; print @ARGV; print "\nend:\n"; open (paraTmp,"> ptmp.txt"); print paraTmp "\nbegin:\n"; print paraTmp @ARGV; print paraTmp "\nend:\n"; close paraTmp; exit;
and i got nothing from @ARGV,
Is it a problem of Activeperl ?
P.S. i 've made a schedule with "netstat -a", it has no problem to get "-a". Thanks

Replies are listed 'Best First'.
Re: How to set Parameter for a .pl in Windows Task Scheduler?
by Corion (Patriarch) on Sep 24, 2003 at 12:10 UTC

    Without having seen your actual entries in the Task Scheduler, I guess that the problem stems from your way of calling the Perl script.

    I guess that you put a direct link to the Perl script into the task entry - try replacing that with the path to Perl.exe and put the script as the first parameter after that:

    "d:\perl\bin\perl.exe" "d:\scripts\test.pl" arg1 arg2 arg3

    Then, the parameter passing should work.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      Thank you Corion!
      Your guess is correct, but i still wonder why it can't find perl.exe(i 've already writen in header)
      anyway, it runs now.
        Very simply put, Windows does not understand the shebang (#!) line. That is a Unix-only convention. I would suggest checking the docs that come with ActiveState Perl about commandline usage. Look at the "Perl/html/faq/Windows/ActivePerl-Winfaq4.html" document, it should have most if not all of the answers you might be looking for in this matter.

        Hope that helps. Happy reading :-)


        "Ex libris un peut de tout"