in reply to redirecting output from a system command to a text file

$a is a bad choice of variable names (as would $b), since it is a magic variable used in custom sorts, however I very much doubt if that is an issue here.

The rediection should work, and the creation of the file shows that the shell (probably cmd.exe) is creating the output file. A few things spring to mind that can create issues with cmd.exe:
Does the command-line (including $a) contain any quotes (other than the outer " used for Perl interpolation)?
Does the parameter in $a contain any imbedded whitespace?

You might like to replace the ./TVT.exe with echo to eliminate these issues. If that gets redirected correctly then you might need to look at the program. For example, is it writing to STDERR?

Update: I have done some experimenting, and cmd.exe does not seem particularly happy with the ./ prefix to the exe. I know you say it worked previously, but try removing it (it is not needed in Windows because the current directory is searched, whether it is in the %path% or not).

Replies are listed 'Best First'.
Re^2: redirecting output from a system command to a text file
by Anonymous Monk on Apr 19, 2011 at 20:09 UTC
    Actually, I got it to work by putting ticks around the $a: system("./TVT.exe '$a' >test.txt"); I am not quite sure why that worked, but it does.
      I just noticed that you are running under Cygwin in one of your replies, so the stuff about the current directory and %path% does not apply.

      There must be a char in the filename that the shell finds interesting.
        Hmm. OK, I am back to square 1. the ticks around a does NOT work, it's just that the exe naturally will run on ALL pdf's in a directory.
Re^2: redirecting output from a system command to a text file
by Anonymous Monk on Apr 19, 2011 at 20:42 UTC
    In this instance the entire name is: Test/W001#00100/TestReport_W001#00100_110327_235516.pdf When I removed the "./" it says it can't find the command.