in reply to Re: Re: system call in an CGI perl script, fails on Windows XP
in thread system call in an CGI perl script, fails on Windows XP

Oh, ok, a couple of things. First, when I said print your path, what I really meant was print the system's environment variable "PATH" (the one that looks like this: PATH=C:\;C:\Windows;C:\Windows\System;.....etc). Not the path to perl.

But I think I see the other problem. If you want to run another Perl script using system, it's possible that your registry doesn't know that .pl means to invoke the Perl intrepreter. On my Windows XP system, when I want to run a Perl script I have to create a copy of the batchfile, runperl.bat, to be scriptname.bat, and run the .bat file, which in turn runs the script. The alternate way of running a Perl script on my WinXP system is to spell it out: perl scriptname.pl.

So keeping that in mind, it might be necessary for your system command to be system ("perl t.pl");, or since this is CGI, system ("perl -wT t.pl");

Of course there are other ways of invoking another Perl script from within Perl as well. (use, require, do, fork, open a pipe, or even reading it in as text and using eval on it. It just depends on what you need.)

UPDATEI forgot to mention one of the most obvious things: Try supplying a complete path instead of just the relative filename of the script you're trying to run. See what happens. The error message "No such file or directory." is telling you something.

Dave

"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Replies are listed 'Best First'.
Re: Re: Re: Re: system call in an CGI perl script, fails on Windows XP
by sureshr (Beadle) on Sep 27, 2003 at 19:20 UTC
    I just tried to use the full path AND with 'perl -wT' and it works. So effectively, it looks are the system is not inherting the parent's properties for some reason.

    I am just confused with this difference in behaviour between in XP & Win2K, than the problem itself. If this is the real problem (property inheritance), then more people would be affected than just me...

      I would reccoment using the start command like this

      my $rv = system("cmd /c START C:\\YourPath\\Here\\t.pl"); Then just make sure the registry associates the file type with the perl interpreter.

      To set your file association in WindowsXP
      1. Open Windows Explorer
      2. Choose Tools->Folder Options
      3. Select the File Types tab
      4. Check for an entry with Extension PL
      5. if(exists($entry)) { $double_check_association = 1; } else(!exists($entry)) { $add_new_entry = 1; }
      6. To add a new association click the "New" button, Enter the extension and then choose the program that should open it
Re: Re: Re: Re: system call in an CGI perl script, fails on Windows XP
by sureshr (Beadle) on Sep 27, 2003 at 19:09 UTC
    You might also want to note that it works fine on Win2K. And my .pl files are associated to be run using the perl interpreter. So, I think that should not really be a problem.

    Since the PATH is printed from the cgi perl script, I would assume that it would be inherited by the 'system' call within it. Correct me, if I am wrong here. And the perl script that I am calling has the correct program association for execution and also, it is available in the path. The error message says that "No such file or directory", means its not able to locate this file, though the PATH has my script :(

    -sureshr
A reply falls below the community's threshold of quality. You may see it by logging in.