CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
Need your help regarding CGI



May 27, 2003, 10:33 PM

Post #1 of 6 (2333 views)
Need your help regarding CGI Can't Post

Hi Everybody,

As a naive cgi programmer, I want to get rid of a problem, for that, I am keen, awaiting your suggestions. I doubt, I could not present my case in front of you properly. Anyway, my problem spins around the following.

I am running a CGI script in which I am running a system command. The scripts is as follows:

#!/usr/bin/perl -w
use strict;
use CGI;
print "Content-type:text/html\n\n";
my $query = new CGI;
my $seq1 = $query->param("seq1");
my $seq2 = $query->param("seq2");
print FH_seq1 "$seq1\n";
print FH_seq2 "$seq2\n";

/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile


Above I am using the system command to run the program
"water" which should write the output into file "water.out", which is not writing anything to this file.
I've given all permission to these files as:

-rwxr-xr-x 1 soumya soumya 2978221 Jun 15 10:26
-rwxr-xr-x 1 soumya soumya 4912 Jun 13 08:25 water
-rwxrwxrwx 1 apache apache 36 Jun 16 05:18
-rwxrwxrwx 1 apache apache 36 Jun 16 05:03
-rwxrwxrwx 1 soumya soumya 48 Jun 16 05:18

But if I use the first file in the directory i.e.
blastall in the script as

my $out = `./blastall`;
print $out;

I get the proper output.

Could you please suggest me any solution for this.

Looking forward for your suggestions,

With regards,

New User

May 28, 2003, 12:17 AM

Post #2 of 6 (2331 views)
Re: [Nandi,S] Need your help regarding CGI [In reply to] Can't Post

Are you sure, your water-command runs? Is it a script? Verify that it runs by adding something like

touch /tmp/water-ran

and looking for the existance and filedate of /tmp/water-ran after using your script.

You should also close your files before starting water. I think water will try to read them.


May 28, 2003, 3:06 AM

Post #3 of 6 (2326 views)
Re: [Skeeve] Need your help regarding CGI [In reply to] Can't Post

Thank you very much,

Water is running, if I run it in command line (same command as used in CGI script) i.e. writing the output into water.out file.
I've also tried "touch /tmp/water-ran" in my cgi script as `touch /tmp/water-ran`;
and found the water-ran in /tmp directory.


Thaumaturge / Moderator

Jun 2, 2003, 1:17 AM

Post #4 of 6 (2313 views)
Re: [Nandi,S] Need your help regarding CGI [In reply to] Can't Post

In Reply To

/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile

This probably doesn't solve your problem, but I wanted to point out that you are misusing the backticks (` ... `).

The point of backticks is to run an external program and capture the output like this:

my @files = `ls dir`;

You don't capture the output from your program so you ar forcing Perl to do unnecessary work. It stores all the output returned by your external program, only to then throw it all away.

If you want to run a program without capturing the output, then you'd be better off using "system".

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Jun 2, 2003, 9:48 PM

Post #5 of 6 (2308 views)
Re: [davorg] Need your help regarding CGI [In reply to] Can't Post

Thanks Dave,

I've tried as bellow:

my $programtorun = 'water';
my @parameters =
\/var\/www\/cgi-bin\/emboss\/water2.seq -gapopen 10
-gapextend 5 -outfile
#my @parameters =
/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile
my @cmdline = ( $programtorun, @parameters );
system (@cmdline);

I've also tried as

system ('water', 'water1.seq', 'water2.seq',
'-gapopen', '10', '-gapextend', '5', '-outfile',
#system ('./water', 'water1.seq', 'water2.seq',
'-gapopen 10', '-gapextend 5', '-outfile water.out');
#system ('water', 'water1.seq', 'water2.seq',
'-gapopen 10', '-gapextend 5', '-outfile water.out');

But none worked.

Could you please suggest me what might be the error. The
other program like blast is working fine.

with regards,


Jun 3, 2003, 6:39 PM

Post #6 of 6 (2300 views)
Re: [Nandi,S] Need your help regarding CGI [In reply to] Can't Post

#First full path to program should be used.

my $programtorun = '/var/www/cgi-bin/emboss/water';

#Why do the first two parameters not have swithches?

my @parameters =('/var/www/cgi-bin/emboss/water1.seq',
'-gapopen 10',
'-gapextend 5'
'-outfile /var/www/cgi-bin/emboss/water.out');

system ($programtorun, @parameters );


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives