I'm trying to get a Perl script to run in the iw-bin directory. If I run it from the command line, the output comes out fine from the script. Nothing seems amis. However if I type the address for the script in the browser and run it from there, I get an internal server error. Upon further investigation, it seems to be inserting data into the output stream before my script gets to it:
[Wed May 25 11:03:40 2005] [error] [client 132.246.18.2] Premature end of script headers: /cms/iw-home/httpd/iw-bin/genContacts.ipl
This script is supposed to be called via a JavaScript as well. The code calling the CGI script is as follows:
var server = window.location.hostname;
IWDatacapture.callServer("http://" + server + "/iw-bin/genContacts.ipl", opt[ownerName].value);
The script is chmoded to 775, which should be sufficent to run it....and it does run perfectly from the command line.
Any ideas?
Perl script excerpt
----------
#!/cms/iw-home/iw-perl/bin/iwperl
use DBI;
use DBD:

racle qw(

ra_types);
BEGIN {
$ENV{ORACLE_HOME} = "/usr/local/oracle/9.2.0";
};
my $dbh;
my $list = '';
connect_to_database();
my $id = $ARGV[0];
if($id eq '') { $id="010001010"; }
my
@contacts = dbquery("select firstname, lastname, contactid, orgid from contact where orgid=" . $id . "order by lastname, firstname");
my $k = 0;
for(my $i = 0; $i<$#contacts; $i += 4) {
$list .= "arrData[$k] = new Array(4);\narrData[$k][0] = $contacts[$i];\narrData[$k][1] = \"$contacts[$i+1]\";\narrData[$k][2] = $contacts[$i+2];\narrData[$k][3] = $contacts[$i+3];\n\n";
$k++;
}
$dbh->disconnect();
print <<EOF;
Content-Type: text/html
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var arrData = new Array($k);
$list
</SCRIPT>
</HEAD>
<BODY onLoad="parent.getScriptFrame().updateContacts(arrData)">
</BODY>
</HTML>
EOF
Edited by aosmond on 05/25/05 08:19 AM (server time).