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

Hi, I have a perl program running on windows on IIS Server , i need to call an exe and pass a filename along with the file path and that exe encrypts the file , when i call the exe using (system or |) the file is truncated but nothing written and when i check the process list i see the exe running ..but the same works from command line Can somebody help me on this

Replies are listed 'Best First'.
Re: Calling an exe from perl on IIS
by BrowserUk (Patriarch) on Sep 04, 2003 at 14:41 UTC

    Have you checked the server logs for error messages?

    Are you checking the return code from system or open (I assume this is what you mean by '|')?

    If you posted the relevant piece of code it would help.

    This sounds like a "permissions problem". When you run the program from the command line, it has the permission of your log on id. When you run the program from IIS, is has the (severaly restricted) permissions of the IUSR_machinename account, which probably means that it doesn't have appropriate access to the directory or the file your are trying to encrypt.

    This is a guess, but a quick check of the IIS server logs should easily tell whether it is a good one or not.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Calling an exe from perl on IIS
by inman (Curate) on Sep 04, 2003 at 15:35 UTC
    The system command will create a new process and return immediately while the process continues to run. Try using backticks to execute your external application. This waits for the spawned process to finish and can be used to slurp all of the data that the process wrote to STDOUT.

    E.g.

    my $data_file = "file.txt"; my $ret=`encrypt.exe $data_file`;

    Inman

      The system function waits for the process to finish. The only difference between backticks and system is that backticks capture the stdout from the program. If the output isn't needed, it is better to use system.
Re: Calling an exe from perl on IIS
by tcf22 (Priest) on Sep 04, 2003 at 14:39 UTC
    Sounds like a permissions issue. Does the IUSR_xxxx user account have access to write to the target directory.