Front page | perl.beginners |
Postings from December 2011
Re: open bug?
Thread Previous
From:
Tessio Fechine
Date:
December 8, 2011 13:19
Subject:
Re: open bug?
Message ID:
CAKp6VawXGOc0ROKzzQVJFT_GHJi9tAtPG-GyE0UH6ySHRijYSg@mail.gmail.com
2011/12/8 Shlomi Fish <shlomif@shlomifish.org>
> On Thu, 8 Dec 2011 16:42:45 -0300
> Tessio Fechine <oissetf@gmail.com> wrote:
>
> > Hello,
> > I have a perl script that uses Net::LDAP to query an directory service.
> It
> > is invoked like this:
> >
> > ---
> > search.pl '(cn=peter*)'
> > ---
> >
> > Today I started another perl script that works on top of search.pl. It
> > opens search.pl with a piped open, and them process the results.
> > But I accidentally found that open acted oddly when '(cn=string*)' was
> > passed to it.
> > The possible bug is that when I pass a nonexistent file name fallowed by
> > '(cn=string*)' to open, it do not fail.
> >
> > ---
> > #!/usr/bin/perl -w
> >
> > use strict;
> >
> > # this fail as expected
> > # open my $search, "nonexistent-script.pl argument|" or die("error:
> $!\n");
> >
> > # this does not
> > open my $search, "nonexistent-script.pl '(cn=peter*)'|" or die("error:
> > $!\n");
> >
> > print "This should not appear.. but it does..\n";
>
> The problem here I think is because the pipe-open spawns a shell which
> fails
> later on. Try this code:
>
> [CODE]
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> open my $search, "nonexistent-script.pl '(cn=peter*)'|" or die("error:
> $!\n");
>
> print "Foo\n";
>
> if (!close($search))
> {
> die "Close failed - $!";
> }
> [/CODE]
>
> Here the close fails.
>
> Regards,
>
> Shlomi Fish
>
>
> > ---
> >
> > Thanks for your time.
>
>
>
> --
> -----------------------------------------------------------------
> Shlomi Fish http://www.shlomifish.org/
> http://www.shlomifish.org/humour/ways_to_do_it.html
>
> Chuck Norris read the entire English Wikipedia in 24 hours. Twice.
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>
Hello,
Here it fails to..
--
Close failed - at test.pl line 13.
--
Thread Previous