prematurely closed filehandle

Discussion in 'Perl Misc' started by Jim, Jun 29, 2006.

  1. Jim

    Jim Guest

    Hi,
    The problem description is below. I would like for Script 2 to work
    within IIS. Any feedback would be greatly appreciated. Thanks!
    Jim

    Windows XP SP2
    ActivePerl 5.8.2 Build 808

    Script 1
    Run from the command line, this script works just fine, with or without
    #!/usr/local/bin/perl -w

    #!/usr/local/bin/perl -w
    use CGI qw:)standard);
    use Win32::OLE;
    open RUNBLAST2, "| C:\\Inetpub\\wwwroot\\port\\blast\\blastall -e .01
    -p blastp -d C:\\Inetpub\\wwwroot\\port\\blast\\db\\gbpoxpep -F F -m 7
    -o C:\\Inetpub\\wwwroot\\webtemp\\152895786322021484375.xml ";
    print RUNBLAST2 ">CNPV-WC93:007\nMKSYDDKVKE LYSAIESNDK";
    close RUNBLAST2 ;
    exit(0);


    Script2
    Accessed via IIS, this script has a problem:
    print() on closed filehandle RUNBLAST2 at
    c:\inetpub\wwwroot\port\blast\blast_xml_run_p.pl line 8.
    If I remove #!/usr/local/bin/perl -w, the script still doesn't work,
    but no error message is returned.

    #!/usr/local/bin/perl -w
    use CGI qw:)standard);
    use Win32::OLE;
    print header(), start_html(-title=>'Test',
    #-BACKGROUND=>'pebblebackgrd.gif',
    -BGCOLOR=>'#FFFFFF');
    open RUNBLAST2, "| C:\\Inetpub\\wwwroot\\port\\blast\\blastall -e .01
    -p blastp -d C:\\Inetpub\\wwwroot\\port\\blast\\db\\gbpoxpep -F F -m 7
    -o C:\\Inetpub\\wwwroot\\webtemp\\152895786322021484376.xml ";
    print RUNBLAST2 ">CNPV-WC93:007\nMKSYDDKVKE LYSAIESNDK";
    close RUNBLAST2 ;
    print end_html();
    exit(0);
     
    Jim, Jun 29, 2006
    #1
    1. Advertisements

  2. Jim

    Dr.Ruud Guest

    Jim schreef:
    You should always check for the open to succeed.

    #!perl
    use strict ;
    use warnings ;
    use CGI qw:)standard) ;
    use Win32::OLE ;

    my $root = 'C:/Inetpub/wwwroot' ;
    my $blast = "$root/port/blast" ;

    open RUNBLAST2,
    "| $blast/blastall" .
    " -e .01" .
    " -p blastp" .
    " -d $blast/db/gbpoxpep" .
    " -F F" .
    " -m 7" .
    " -o $root/webtemp/152895786322021484375.xml"
    or die "Ouch: $!" ;

    etc.

    (untested)
     
    Dr.Ruud, Jun 29, 2006
    #2
    1. Advertisements

  3. Jim

    Jim Guest

    Dr. Ruud,

    Thank you for the reply and the advice!

    This script (below) runs fine from the command line, but not in IIS,
    when browsed to from Internet Explorer. The error message is:

    Ouch: Bad file descriptor at
    c:\inetpub\wwwroot\port\blast\blast_xml_run_p.pl line 13.

    Might you have any idea what causes the "Bad file descriptor" message?

    Jim


    #!perl
    use strict;
    use warnings;
    use CGI qw:)standard);
    use Win32::OLE;
    my $root = 'C:/Inetpub/wwwroot' ;
    my $blast = "$root/port/blast" ;
    print header(), start_html(-title=>'Invalid Form Variables',
    #-BACKGROUND=>'pebblebackgrd.gif',
    -BGCOLOR=>'#FFFFFF');
    open RUNBLAST2,
    "| $blast/blastall" .
    " -e .01" .
    " -p blastp" .
    " -d $blast/db/gbpoxpep" .
    " -F F" .
    " -m 7" .
    " -o $root/webtemp/1528957863220214843.xml"
    or die "Ouch: $!" ;
    print RUNBLAST2 ">CNPV-WC93:007\nMKSYDDKVKE LYSAIESNDK";
    close RUNBLAST2 ;
    print end_html();
    exit(0);
     
    Jim, Jun 29, 2006
    #3
  4. Jim

    Jim Guest

    **************
    Clarification:
    The "line 13" from the error message corresponds to the "open
    BLASTRUN2,..." line.

    Jim
     
    Jim, Jun 29, 2006
    #4
  5. Jim

    Jim Moon Guest

    I have determined the cause of the error. It was a permissions issue.
    Hence "Bad file descriptor". I rarely work with Perl, so my familiarity is
    minimal. It is an interesting and useful language though!

    --Jim
     
    Jim Moon, Jun 29, 2006
    #5
  6. Jim

    Dr.Ruud Guest

    Jim schreef:
    google: perl iis "bad file descriptor"

    will find you stuff like:
    http://mail.pm.org/pipermail/spug-list/2006-May/007247.html
     
    Dr.Ruud, Jun 29, 2006
    #6
  7. Jim

    Dr.Ruud Guest

    Jim Moon schreef:
    Another pointer: perldoc -q browser
     
    Dr.Ruud, Jun 29, 2006
    #7

  8. Please choose one posting address and stick with it.

    ^^^^^^^^^^^^

    perldoc -q "command line"

    My CGI script runs from the command line but not the browser. (500
    Server Error)


    Then it was not a Perl problem.


    That is irrelevant, since you did not have a Perl problem to begin with.
     
    Tad McClellan, Jun 30, 2006
    #8
  9. Jim

    Jim Moon Guest

    I'll think about it.
    Given my unfamiliarity with Perl and no knowledge of what "Bad file
    descriptor" might actually mean, I believe that you may be mistaken.
    Given my unfamiliarity with Perl and no knowledge of what "Bad file
    descriptor" might actually mean, I believe that you may be mistaken.
     
    Jim Moon, Jul 7, 2006
    #9
  10. Given your unfamiliarity with Perl, perhaps you'd be better off taking
    advice from those who *are* familiar with it, instead of arguing with
    them.

    Not a flame, just advice.

    sherm--
     
    Sherm Pendley, Jul 7, 2006
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.