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

O, Great Monks, I've a problem which seems a bit odd and has me both stumped and stupefied

My operating environment is Windows XP Pro. I am developing a program as a wrapper for an InstallShield 11.5 command line build; my program edits the project file (which resembles XML in overall format). This part is not the problem.

The problem is that the program writes a command line ($command). When the command is executed by means of either system($command) or open(my $fh, "$command |") or die, the command fails. My first thought was "no mystery, here. I'm an idiot and screwed up the command line". This thought was wrong. The command line written by my program works fine when executed from the command prompt or from a .bat file. I'm now a confused. Why should this happen? I'm wondering if any of these modules overload either system or open.

use Carp; use ActiveState::DateTime qw(check_date); use Cwd; use Fcntl; use Getopt::Long; use Pod::Usage; use POSIX ; use Tie::File; use Tk; use Win32; use Win32::Process; use Win32API::File qw(:ALL); use constant

Update

After some prodding by CountOrlok (thank you), I poked and tested a bit more thoroughly. My problem occurs because a tied file does not appear to be getting untied; the untie returns an error (untie attempted while 1 inner references still exist).


Reformatted per suggestion by jdporter.

emc

" When in doubt, use brute force." — Ken Thompson

Replies are listed 'Best First'.
Re: Execution fails from within Perl; succeeds outside Perl
by CountOrlok (Friar) on Mar 13, 2006 at 18:05 UTC
    When you say "the command fails", do you mean, nothing happens? Does the die statement from the open mention anything? Nothing in any of the special error variables?

    Is the path for the command fully spelt out in the $command variable>

    Before you think that one of the modules you mentioned is overloading system or open, did you try calling the $command using system or open without any modules loaded?

    -imran

      When you say "the command fails", do you mean, nothing happens? Does the die statement from the open mention anything? Nothing in any of the special error variables?

      No, the command line is executed; the command fails with an internal error. I've done more checking and found the problem is related to tieing the file that's being modified. Unfortunately, the untie command gives me an error: untie attempted while 1 inner references still exist. Since in my toy test script, all I do with File::Tie is tie a file to the array and immediately untie it, I'm slightly confused. Still.

      emc

      " When in doubt, use brute force." — Ken Thompson