John Lin wrote:
Hi list,

I have written a perl CGI script that basically executes a system command via an open command like so:

open (COMHANDLE, '/usr/local/bin/gpg --no-tty --list-keys |') or die "can not list keys \n";
print <COMHANDLE>;
close (COMHANDLE) or die "can not close COMHANDLE \n";

For some reason, if I run this CGI script in the command line, it executes correctly (I get a list of keys in the shell).
But when i try to run this script in a browser, nothing is printed in the borwser.

I have also tried with a simpler script that basically gets the system date and output it like so:

open (COMHANDLE, 'date |') or die "Can not get system date \n";
print <COMHANDLE>;
close (COMHANDLE) or die "Can not close COMHANDLE \n";

But with this script, I can run it both in the shell and in a browser and I get the system date.
I am not really sure what the problem is at this time.... Any help is welcome!

gpg depends on the user that you are running the command as, and requires either more options or a home directory. When you are running it command line are you running it as the same user as the web server? Are you trying to get your list of keys or the user the web server is running as keys'?

As a side note it might be simpler to just use backticks instead of an open call, unless you are planning on doing something more interesting than reading the output, but then chances are you aren't going to want to do it this way with gpg anyways. (I can explain why if it is the case).

For instance:

my @output = `/usr/local/bin/gpg --no-tty --list-keys`;
print @output;

Don't forget to check $?...

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to