Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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:// ) on Fedora 8,

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 :


      (/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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2020-09-24 02:18 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.