I am attempting execute a perl script that calls R from a browser.  My test script currently executes the R code which creates a plot as a png and displays the png file in the browser.  The perl code executes fine under the command line but the R code does not appear to be called when executed from the browser (png file does not update).  I am currently storing the perl script in ~/Sites and calling from the browser by http://localhost/~carlp/htmltest.cgi.  When I refresh the browser, top will show perl and R start briefly and although the perl code executes, the R code does not.  The R code itself queries a MySQL database though a JDBC connection.  The test perl code is as follows:
#!/usr/bin/perl#htmltest.cgiuse strict;use warnings;use IPC::Open2;use CGI;
createPlot();printHTML();
sub createPlot {	my @projects = ("Project1","Project2"); 	my $line = "test";
	my $pid = open2(*READ_R, *WRITE_R, '/usr/bin/R', '--slave', '--silent', '--args', @projects);	print WRITE_R "		Args = commandArgs(TRUE)		source('/Users/carlp/Documents/RWork/QueryFunctions.R');		png('/Users/carlp/Sites/plot.png',height = 600,width = 800);		plotDailyByProject(Project = Args,Year=2010,Species = 'Chinook');		dev.off();		q('no')	";
	while ($line = <READ_R>) {  		chomp $line;  		#print "[$line]\n"; 	}	close(WRITE_R);	close(READ_R);}
sub printHTML {	my $cgi = new CGI;	print $cgi->header(),$cgi->start_html("Welcome to htmltest.cgi");	print $cgi->center("Plots Generated in R");	print '<img src="plot.png">';	print $cgi->end_html();}
I was unsure whether to post this to the mac list since I am using Mac OS X 10.6.7 or to the general help list but I thought I'd try here first.  Any suggestions would be greatly appreciated!
-Carl
	[[alternative HTML version deleted]]

