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

perl system function

From:
prathima prakash
Date:
April 1, 2002 01:43
Subject:
perl system function
Message ID:
F25xTTpSRXCbcxvWeqz0000e415@hotmail.com

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 displayed...it 
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!!
bye,
prats.

the script is as follows:
--------------------------

#!/usr/bin/perl
print "content-type: text/html\n\n";
use strict;
use DBI;

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

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

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

open IN, "seqout";

   $sth->finish();
   $dbh->disconnect();

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
system("clear");


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

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

my @output = ();
open(OUTPUT,"seqout.blast");
@output = <OUTPUT>;

print <<HTML;
<html>
<head>
   <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; 
charset=iso-8859-1\">
   <META NAME=\"Author\" CONTENT=\"Prathima\">
   <META NAME=\"GENERATOR\" CONTENT=\"Mozilla/4.04 [en] (Win95; I) 
[Netscape]\">
   <title>Plant lectins</title>
</head>
<body background="/pdb1dlp.gif">
<p>
<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>
@output
<BR><BR><BR>
<center>
</body>
</html>
HTML
;





_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About