[Bioperl-l] Permission denied when using Bio::SearchIO in CGI
script
Jason Stajich
jason at cgt.mc.duke.edu
Mon Jan 27 08:06:08 EST 2003
When you do a 'POST' it sends the data not the filename, if you are
expecting people to post their own blast files from their computers you
can't expect it to read the data from their computer as if the file was
resident on the webserver (which is what the -file => $filename directive
expects).
You want to use the filehandle not the filename. Try passing in:
-fh => $fh
instead of
-file => $fh
to SearchIO.
-jason
On Mon, 27 Jan 2003, Marcus Claesson wrote:
>
> Thanks for your answers!
>
> > This is an error in your directory permissions or something (check the
> > group read/write on teh file that is created with an ls -l). Bioperl
> > does nothing "fancy" about opening files and can't change permissions
> > (obviously) of a file.
>
> I noticed that too but the problem is, though I can control
> persmissions and locations on my own local files, I cannot do it on a
> remote user's files. The purpose of this cgi script is for web users to
> parse their local blast output files and upload the result file onto my
> server.
>
> The Bio::Search module behaves differently than the "PerlCGI-way" to open
> files. Here's an example:
>
> Both these methods work fine when I run the script on a local file with
> the right permissions:
>
> #!/usr/bin/perl -wT
> use CGI qw(:standard);
> use Bio::SearchIO;
> print $q->filefield(-name=>'file', #A cgi function to browse and
> select files to open
> -size=>20),$q->br;
> print $q->submit(-name =>'upload',
> -value =>'Upload file'),$q->br;
> if (param('upload')) {
> $fh = $q->upload('file');
> $in = new Bio::SearchIO(-format => 'blast',
> -file => $fh);
> while(<$fh>) {
> print $_; }
> while($result = $in->next_result) {
> etc,etc... }
> }
>
> But when I try to open C:\Temp\blastfile.out from a remote windows station
> I get this error message:
>
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: ------------- EXCEPTION -------------,
> referer: http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: MSG: Could not open C:\Temp\blastfile.out
> for reading: No such file or directory, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK Bio::Root::IO::_initialize_io
> /usr/lib/perl5/site_perl/5.8.0/Bio/Root/IO.pm:244, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK Bio::Root::IO::new
> /usr/lib/perl5/site_perl/5.8.0/Bio/Root/IO.pm:192, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK Bio::SearchIO::new
> /usr/lib/perl5/site_perl/5.8.0/Bio/SearchIO.pm:121, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK Bio::SearchIO::blast::new
> /usr/lib/perl5/site_perl/5.8.0/Bio/SearchIO/blast.pm:200, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK Bio::SearchIO::new
> /usr/lib/perl5/site_perl/5.8.0/Bio/SearchIO.pm:134, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: STACK toplevel
> /var/www/cgi-bin/bxbrowser1.pl:25, referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: , referer:
> http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
> [Mon Jan 27 10:58:38 2003] [error] [client 143.239.131.75] [Mon Jan 27
> 10:58:38 2003] bxbrowser1.pl: --------------------------------------,
> referer: http://nsfm39.ucc.ie/cgi-bin/bxbrowser1.pl
>
> Thus, Bio::Search can't even find the file. But to open it and print the
> contents in the 'normal cgi-way' works fine i.e
> while(<$fh>) {
> print $_;
> }
>
> Howcome do you think?
>
> Regards,
> Marcus
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>
--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu
More information about the Bioperl-l
mailing list