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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



Nandi,S
Novice

May 27, 2003, 10:33 PM

Post #1 of 6 (1107 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;
open(FH_seq1,">/var/www/cgi-bin/emboss/water1.seq");
open(FH_seq2,">/var/www/cgi-bin/emboss/water2.seq");
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/water
/var/www/cgi-bin/emboss/water1.seq
/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile
/var/www/cgi-bin/emboss/water.out`;

#---END---

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
blastall
-rwxr-xr-x 1 soumya soumya 4912 Jun 13 08:25 water
-rwxrwxrwx 1 apache apache 36 Jun 16 05:18
water1.seq
-rwxrwxrwx 1 apache apache 36 Jun 16 05:03
water2.seq
-rwxrwxrwx 1 soumya soumya 48 Jun 16 05:18
water.out

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,
Soumyadeep


Skeeve
New User

May 28, 2003, 12:17 AM

Post #2 of 6 (1105 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

Code
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.


Nandi,S
Novice

May 28, 2003, 3:06 AM

Post #3 of 6 (1100 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.

Regards
Soumyadeep


davorg
Thaumaturge / Moderator

Jun 2, 2003, 1:17 AM

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


In Reply To

Code
`/var/www/cgi-bin/emboss/water 
/var/www/cgi-bin/emboss/water1.seq
/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile
/var/www/cgi-bin/emboss/water.out`;


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:

Code
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
http://www.dave.org.uk/
Get more help at Perl Monks


Nandi,S
Novice

Jun 2, 2003, 9:48 PM

Post #5 of 6 (1082 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 =
qw/\/var\/www\/cgi-bin\/emboss\/water1.seq
\/var\/www\/cgi-bin\/emboss\/water2.seq -gapopen 10
-gapextend 5 -outfile
\/var\/www\/cgi-bin\/emboss\/water.out/;
#my @parameters =
qw(/var/www/cgi-bin/emboss/water1.seq
/var/www/cgi-bin/emboss/water2.seq -gapopen 10
-gapextend 5 -outfile
/var/www/cgi-bin/emboss/water.out);
my @cmdline = ( $programtorun, @parameters );
system (@cmdline);


I've also tried as

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');
#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,
Soumyadeep


Haunter
Novice

Jun 3, 2003, 6:39 PM

Post #6 of 6 (1074 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',
'/var/www/cgi-bin/emboss/water2.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