R
Rob
I have a small CGI script that attempts to create a file on the fly.
The script runs successfully from the command prompt. Although when I
execute in a browser the file does not get created and therefore the
contents are not displayed on the page. I have try several different
approaches all have fialed to correct this issue. I have checked the
promissions, I am login in under the httpd userid, I have checked the
rc on the system command(see below), and have hit the wall.
HERE IS THE SCRIPT:
****************************************************************************
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my @fcetabs;
my @tablist;
my $dbin=param('database');
system("./list $dbin _ list.$$") || print "Bad Return Code from system
call: $?\n";
open(FCELST, "list.$$") || print "Database $dbin is currently
unavailable: $!";
while(<FCELST>){
@fcetabs=split;
push @tablist, $fcetabs[0];
}
close(FCELST);
system("rm ./list.$$");
print header;
print start_html('Table Selection');
showtabs(@tablist);
print end_html;
sub showtabs {
print start_form(-name=>'lstfield'),
h2('Please select a table for list of fields:'),
radio_group(-name=>'tables',-values=>[@_]),
p(),
submit(-name=>'lflds',-label=>'List Fields'),
end_form;
}
HERE IS THE OUTPUT FROM THE COMMAND LINE:
****************************************************************************
/cgi-bin> listfce.cgi database=sample
Bad Return Code from system call: 0
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Table Selection</TITLE>
</HEAD><BODY><FORM METHOD="POST"
ENCTYPE="application/x-www-form-urlencoded" NAME="lstfield">
<H2>Please select a table for list of fields:</H2><INPUT TYPE="radio"
NAME="tables" VALUE="cust_items" CHECKED>cust_items<INPUT TYPE="radio"
NAME="tables" VALUE="customers">customers<INPUT TYPE="radio"
NAME="tables" VALUE="households">households<INPUT TYPE="radio"
NAME="tables" VALUE="item_codes">item_codes<INPUT TYPE="radio"
NAME="tables" VALUE="items">items<INPUT TYPE="radio" NAME="tables"
VALUE="promo_codes">promo_codes<INPUT TYPE="radio" NAME="tables"
VALUE="promotions">promotions<INPUT TYPE="radio" NAME="tables"
VALUE="transactions">transactions<P><INPUT TYPE="submit" NAME="lflds"
VALUE="List Fields"><INPUT TYPE="hidden" NAME=".cgifields"
VALUE="tables"></FORM></BODY></HTML>
For some reason the or condition trips for the system command,
although the rc is zero. The HTML is correct, when pasted into a
..html and viewed it does display properly. Although via a browser
none of the information from the file is on the page???? I removed
the system (rm command and the file does not get created???
The script runs successfully from the command prompt. Although when I
execute in a browser the file does not get created and therefore the
contents are not displayed on the page. I have try several different
approaches all have fialed to correct this issue. I have checked the
promissions, I am login in under the httpd userid, I have checked the
rc on the system command(see below), and have hit the wall.
HERE IS THE SCRIPT:
****************************************************************************
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my @fcetabs;
my @tablist;
my $dbin=param('database');
system("./list $dbin _ list.$$") || print "Bad Return Code from system
call: $?\n";
open(FCELST, "list.$$") || print "Database $dbin is currently
unavailable: $!";
while(<FCELST>){
@fcetabs=split;
push @tablist, $fcetabs[0];
}
close(FCELST);
system("rm ./list.$$");
print header;
print start_html('Table Selection');
showtabs(@tablist);
print end_html;
sub showtabs {
print start_form(-name=>'lstfield'),
h2('Please select a table for list of fields:'),
radio_group(-name=>'tables',-values=>[@_]),
p(),
submit(-name=>'lflds',-label=>'List Fields'),
end_form;
}
HERE IS THE OUTPUT FROM THE COMMAND LINE:
****************************************************************************
/cgi-bin> listfce.cgi database=sample
Bad Return Code from system call: 0
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Table Selection</TITLE>
</HEAD><BODY><FORM METHOD="POST"
ENCTYPE="application/x-www-form-urlencoded" NAME="lstfield">
<H2>Please select a table for list of fields:</H2><INPUT TYPE="radio"
NAME="tables" VALUE="cust_items" CHECKED>cust_items<INPUT TYPE="radio"
NAME="tables" VALUE="customers">customers<INPUT TYPE="radio"
NAME="tables" VALUE="households">households<INPUT TYPE="radio"
NAME="tables" VALUE="item_codes">item_codes<INPUT TYPE="radio"
NAME="tables" VALUE="items">items<INPUT TYPE="radio" NAME="tables"
VALUE="promo_codes">promo_codes<INPUT TYPE="radio" NAME="tables"
VALUE="promotions">promotions<INPUT TYPE="radio" NAME="tables"
VALUE="transactions">transactions<P><INPUT TYPE="submit" NAME="lflds"
VALUE="List Fields"><INPUT TYPE="hidden" NAME=".cgifields"
VALUE="tables"></FORM></BODY></HTML>
For some reason the or condition trips for the system command,
although the rc is zero. The HTML is correct, when pasted into a
..html and viewed it does display properly. Although via a browser
none of the information from the file is on the page???? I removed
the system (rm command and the file does not get created???