in reply to Re: System call doesn't recognise '>'
in thread System call doesn't recognise '>'

Indeed, I used 'system LIST'
I already tried to add all arguments as one, and even tried to add as an array:
@array = ($command, "$arg1 $arg2 > outfile")
system(@array)
Or also:
@array=($command, $arg1, $arg2, "> outfile")
Or also:
@array=("$command $arg1 $arg2 > outfile")
In the last case it didn't even recognise $command, and in the previous cases it tried to open '>' as a possible argument (=backgroundfile)
  • Comment on Re^2: System call doesn't recognise '>'

Replies are listed 'Best First'.
Re^3: System call doesn't recognise '>'
by Bloodnok (Vicar) on Dec 10, 2008 at 14:28 UTC
    What happens if you make the call read: system("$command $arg1 $arg2 > outfile") ?

    Note that, on Windoze, the arguments for system are the same as for exec. However, exec isn't, or wasn't, fully supported on Windoze, I think you might have to use the single string form of the call, so in your case, something along the lines of...

    my @array = qq/$command $arg1 $arg2 > outfile/; system "@array"; # Use perl to stringify the command argument list
    Just a thought...

    A user level that continues to overstate my experience :-))
      my @array = qq/$command $arg1 $arg2 $arg3 > $outfile/; system "@array";

      Resulted in: Can't spawn "cmd.exe": No such file or directory at D:\advanced_programming\test_syscall.pl line 10.

      On the other hand:

      my @array = ($command, "$arg1 $arg2 $arg3 > $outfile");

      system (@array);

      Results in:

      Clover: Cis-eLement OVERrepresentation Compiled on Jul 18 2006 Error: motif and sequence files required Usage summary: clover [options] mymotifs myseqs.fa [BGfiles]
        Does the command work without redirection when run by system?

        A user level that continues to overstate my experience :-))