Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

system "no_such_file" returns a different error on Fedora

by amir_e_a (Hermit)
on Jul 03, 2008 at 08:42 UTC ( #695308=perlquestion: print w/replies, xml ) Need Help??

amir_e_a has asked for the wisdom of the Perl Monks concerning the following question:

It's probably more of an OS question than a Perl question, but i'll try anyway.

It looks like different Unix flavors produce different errors when trying to run system "no_such_file"

I am trying to build Perl ( rsync://public.activestate.com/perl-current/ ) on Fedora 8, 2.6.24.7-92.fc8.

The test t/op/exec.t is failing on line 97. Apparently, running the following code:

system { "lskdfj" } "lskdfj"';

... on Fedora sets $! to "Not a directory". Perl 5.8 on Ubuntu and Perl 5.10 on Cygwin both set $! to "No such file or directory", which would make the test pass.

Is it the expected behavior on Fedora?

Replies are listed 'Best First'.
Re: system "no_such_file" returns a different error on Fedora
by moritz (Cardinal) on Jul 03, 2008 at 09:04 UTC
    Try the following short C program:
    #include <unistd.h> #include <stdio.h> #include <string.h> #include <errno.h> int main(int argc, char** argv){ execl("sadlfjsdf", "foo"); printf("%s\n", strerror(errno)); }

    If that says No such file or directory it's most likely a perl problem, and you should contact p5p. If it says Not a directory, it's most likely a Fedora problem (and I guess you should contact the Fedora developers).

    BTW do you have a single dot in your $PATH? (Don't know if that makes a difference)

      Tried the C code, it says "No such file or directory". p5p then?..

      I don't have a single dot in my $PATH :

      /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/aharoni/bin

      (/home/aharoni is my home dir.)

        Tried the C code, it says "No such file or directory". p5p then?..

        Yes, please. Usually they are very good with this kind of low-level stuff ;-)

Re: system "no_such_file" returns a different error on Fedora
by chromatic (Archbishop) on Jul 03, 2008 at 16:53 UTC

    Hm, that looks like a bad test to me.

    $rc = system { "lskdfj" } "lskdfj"; unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256 or $rc == 512) ) + { print "# \$rc == $rc\n"; } unless ( ok( $! == 2 or $! =~ /\bno\b.*\bfile/i or $! == 13 or $! =~ /permission denied/i or $! == 22 or $! =~ /invalid argument/i ) ) { printf "# \$! eq %d, '%s'\n", $!, $!; }

    By the time something gets around to checking $!, won't all of the system calls performed by ok() and print have set it to something else?

      A good point, although it seems to work like this on my Fedora machine with this minimal program:

      system { "lskdfj" } "lskdfj"; printf "# \$! eq %d, '%s'\n", $!, $!; # prints # $! eq 20, 'Not a dire +ctory'

      Another minor problem i can think of is the "random" command "lskdfj". It's paranoid thinking, but what if the user happens to have a file called /bin/lskdfj ? Maybe it should be checked with -e or something.

      I'd bring it up on perl5-porters, but i am trying to subscribe and not receiving the confirmation email.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://695308]
Approved by kabeldag
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2019-12-09 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?