develooper Front page | perl.beginners | Postings from April 2002

perl system function

prathima prakash
April 1, 2002 01:43
perl system function
Message ID:

hi guys,
The following cgi script works just fine when i run it from the command 
prompt, but when i check using a browser the output is not 
gives error as document contained no data..can i use the system() function 
in cgi as i have done below? the data itself is not fetched from the 
database when i run it using a browser..why is it so? kindly help me with 
this stupid problem of mine!!

the script is as follows:

print "content-type: text/html\n\n";
use strict;
use DBI;

   my $dbh = DBI->connect( 'dbi:mysql:dbname',
                             RaiseError => 1,
                             AutoCommit => 0
                         ) || die "Database connection not made: 

   $a = ' ';
my $env = uc($ENV{ 'QUERY_STRING' });
my $sth = $dbh->prepare( "select seq from table1 where pid = '$env'" );

   $sth->bind_col( 1, \$seq );
     $a = $seq;
open IN, ">seqout" or die "cannot open file for write.\n Error:$!";
  print IN $a;
close IN;

open IN, "seqout";


open NAME, ">filename";
print NAME 'seqout';
print <NAME>;

my (@blast,$tfile);
$tfile = "./filename";

open(FILE,"$tfile")||die "Cannot open $tfile :$!";
@blast=<FILE>; #assign the file to an array

#clear the screen

print(" Please be patient... This may take few minutes...\n");

system("/root/blowp/blowpall -p blowp -d /root/blowp/db/nr -i $infile -o  

my @output = ();
@output = <OUTPUT>;

print <<HTML;
   <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; 
   <META NAME=\"Author\" CONTENT=\"Prathima\">
   <META NAME=\"GENERATOR\" CONTENT=\"Mozilla/4.04 [en] (Win95; I) 
   <title>Plant lectins</title>
<body background="/pdb1dlp.gif">
<font color="black"><font size=+1><br>
<center><b> Blast output for $ENV{ 'QUERY_STRING' } </b></center>
<BR><p><center><IMG SRC="/line1.gif"></center></p>
<BR><font color="black"><font size=+0>

Send and receive Hotmail on your mobile device: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About