For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > October 2006 > Problem with open2 in CGI script only









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with open2 in CGI script only
Jennifer I. Drake

2006-10-23, 6:55 pm

Hello,

I am using open2 to write and read to R. This works correctly when run
from the command line, but not when part of the CGI script. Does
anyone have any ideas what might be causing this?

Thanks,
Jennifer


Here is a sample of the script I am running:

#!/usr/bin/perl

use warnings;
use strict;
use IPC::Open2;
use CGI qw/:all :html3 -nph/;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use GD;

my $outfile = "Rtestout.txt";

my $Rstring = "x<-27\n
x";

my $pid = open2(*READ_R, *WRITE_R, 'R', '--slave', '--silent',
'--vanilla');

open (OUT, ">$outfile") or die "Cannot open outfile: $!\n";

print WRITE_R "
$Rstring
q('no')
";

while (my $line = <READ_R> ) {
print OUT $line;
}

close (OUT);
close (READ_R);
close (WRITE_R);

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com