in reply to Re: On win32 a scheduling task program doesn't work
in thread On win32 a scheduling task program doesn't work

I will try a better explanation:

The Perl code is simply this one:
system "rsync --version";

It is locate in a file:
backup.pl

From MS DOS prompt (I mean: perl -w backup.pl),
It works fine and shows rsync version.

The same code in the same file had that error:

(2 main rsync 4008 C:\Programmi\cwRsync\bin\rsync.exe: *** fata +l error - couldn't initialize fd 0 for /dev/console)

if I try to run the same backup.pl file from Windows Scheduled Task.
That's strange.

Replies are listed 'Best First'.
Re^3: On win32 a scheduling task program doesn't work
by BrowserUk (Patriarch) on Jun 18, 2010 at 22:44 UTC

    Chances are thta this is a "permissions problem". Ie. You have set the task up to run when there is no user logged on, but failed to supply the appropriate user-id / password. .

    But, it could also be a lack of a console, try system "cmd /c rsync --version";

      with:
      system "cmd /c rsync --version";
      I have always:

      2 main rsync 3456 C:\Programmi\cwRsync\bin\rsync.exe: *** fatal error - couldn't initialize fd 0 for /dev/console

        I suspect that you will get more help from a cygwin support forum, as this is neither a Perl nor a windows problem.

Re^3: On win32 a scheduling task program doesn't work
by ikegami (Patriarch) on Jun 18, 2010 at 23:19 UTC

    That's strange.

    That rsync wants a console, that scheduled tasks are run in the background, or that rsync can't find a non-existent console? The first isn't particularly strange, and the second and third sure aren't.

    Can rsync be told to work despite having no console? Does the scheduler give an option to run a task "interactively"?

Re^3: On win32 a scheduling task program doesn't work
by furry_marmot (Pilgrim) on Jun 19, 2010 at 00:16 UTC

    Okay. First, I assume you are using Win XP or Vista, right? The "MS DOS prompt" has been a command shell for quite a while. But anyway, does your code change to the correct directory? The scheduled copy might be starting in a default directory (like your user folder), and thus be in the wrong place.

    I don't think this is Perl problem, since you've demonstrated it works. I suspect it's either a permission problem, or it's starting in the wrong directory. Try checking the current directory from the script that's being run from the Windows Task Scheduler. Also try adding some lines to create or delete files, along with the result.

    --marmot