Both run on UNIX hosts running SunOS 5.9 and Perl 5.8.8.
To debug, I scaled down the problem script to something called testread4.pl. When I run it from the UNIX command prompt, it works fine. It opens the encrypted file and returns 10 line of output. When I call it from the webpage, it shows nothing in the browser. Checking the error_log file, it says:
gpg: cannot open `/dev/tty': No such device or address
It seems like from the web, its not getting all the UNIX environment variables and doesn't recognize /dev/tty.
The code is below:
http://ourhost:8000/cgi-bin/test4.cgi
cat test4.cgi
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/ksh
- . /home/apache1/.profile
- ./testread4.pl
Expand|Select|Wrap|Line Numbers
- #!/usr/local/bin/perl -w
- $gpgPassFile = 'password';
- $fileWithPath= 'test.gpg';
- $dataMax=10;
- print "Start of file read\n";
- open(FILE, "gpg --passphrase-file $gpgPassFile --decrypt $fileWithPath | " ) ||
- die("Unable to open $fileWithPath with gpg!");
- $x=0;
- while (<FILE>) {
- print "<tt> $_\n";
- if ($x >= $dataMax) {
- last;
- }
- }
- close(FILE);
- print "End of file read\n";