in reply to Calling system function in cgi

Instead of:
system("test.exe");
you can try using backtics:
my $results = `test.exe`;
The screen output of running test.exe will be captured in $results.

Although you're not doing it in your example, but if you pass any input from your CGI to the command line, make sure you untaint it first.

Cheers,

Brent

-- Yeah, I'm a Delt.

Replies are listed 'Best First'.
Re^2: Calling system function in cgi
by esskar (Deacon) on Dec 28, 2005 at 14:22 UTC
    instead of using the backtics, i prefer qx

    Edit - after vek slapped me :-) Well, i prefer qx over backtics because it is more readable. my $result = `test.exe`; looks too similar to my $result = 'test.exe';. Using a qx instead signals that something special is happening here.

      While I'm sure you have your reasons for preferring qx/STRING/ over `STRING`, perhaps it would help the OP if you'd expand on your reply a little and explain why. What benefits would the OP get from using one over the other?

      -- vek --