Fork broken???

Discussion in 'Perl Misc' started by ishulz, Feb 16, 2006.

  1. ishulz

    ishulz Guest

    This is simple prog:

    #!/usr/bin/perl -w
    system('/usr/local/bin/cat aaa');

    It works fine and $? = 0

    But this prog:

    #!/usr/bin/perl -w
    system('/usr/bin/ls aaa >bbb');

    doesn't work, and $?=65280, $!='No such file or directory'

    '/usr/bin/ls aaa >bbb' started manually works fine.


    What happens?
     
    ishulz, Feb 16, 2006
    #1
    1. Advertising

  2. ishulz

    sonet Guest

    May be you forgot to point out the full path.
    Especially , when you use crond to run prog.
    Try it!
    system('/usr/bin/bin /path1/aaa > /path2/bbb');


    "ishulz" <> ???
    news: ???...
    > This is simple prog:
    >
    > #!/usr/bin/perl -w
    > system('/usr/local/bin/cat aaa');
    >
    > It works fine and $? = 0
    >
    > But this prog:
    >
    > #!/usr/bin/perl -w
    > system('/usr/bin/ls aaa >bbb');
    >
    > doesn't work, and $?=65280, $!='No such file or directory'
    >
    > '/usr/bin/ls aaa >bbb' started manually works fine.
    >
    >
    > What happens?
    >
     
    sonet, Feb 16, 2006
    #2
    1. Advertising

  3. ishulz

    ishulz Guest

    The same :-(((
     
    ishulz, Feb 16, 2006
    #3
  4. ishulz

    Guest

    ishulz wrote:

    > system('/usr/bin/ls aaa >bbb');


    Are you sure `ls` is in /usr/bin on the system you're working on? On
    my machine (SuSE 9.3), `ls` is in /bin

    --
    http://DavidFilmer.com
     
    , Feb 16, 2006
    #4
  5. ishulz

    ishulz Guest

    '/usr/bin/ls aaa >bbb' started manually works fine.

    It means that /usr/bin/ls and aaa exists and it's possible to create
    and write file bbb.
     
    ishulz, Feb 16, 2006
    #5
  6. ishulz

    Guest

    ishulz wrote:
    <snip>

    OK, lemme get this straight:

    If you type this at a command prompt:

    /usr/bin/ls aaa >bbb

    It works fine (assuming you are in the directory where aaa exists, of
    course)

    But if you type this in the SAME prompt/directory:

    perl -we 'system("cat foo.txt >bbb")'

    it does not work.

    Is that correct?

    --
    http://DavidFilmer.com
     
    , Feb 16, 2006
    #6
  7. ishulz

    Anno Siegel Guest

    ishulz <> wrote in comp.lang.perl.misc:
    > This is simple prog:
    >
    > #!/usr/bin/perl -w
    > system('/usr/local/bin/cat aaa');
    >
    > It works fine and $? = 0
    >
    > But this prog:
    >
    > #!/usr/bin/perl -w
    > system('/usr/bin/ls aaa >bbb');
    >
    > doesn't work, and $?=65280, $!='No such file or directory'
    >
    > '/usr/bin/ls aaa >bbb' started manually works fine.


    What's your shell's reply to "alias /usr/bin/ls"?

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Feb 16, 2006
    #7
  8. ishulz wrote:
    > This is simple prog:


    >
    > #!/usr/bin/perl -w


    > system('/usr/local/bin/cat aaa');
    >
    > It works fine and $? = 0
    >
    > But this prog:
    >
    > #!/usr/bin/perl -w


    > system('/usr/bin/ls aaa >bbb');
    >
    > doesn't work, and $?=65280, $!='No such file or directory'
    >
    > '/usr/bin/ls aaa >bbb' started manually works fine.
    >
    >
    > What happens?


    try this:

    #!/usr/bin/perl
    use strict; use warnings;

    my $file = 'aaa';
    -f $file ? print $file, " is a file\n" : print $file, " is NOT a
    file\n";
    system("/usr/bin/ls $file") == 0 or die "$?\n$!\n";


    ....can you copy/paste the output of that script?
     
    it_says_BALLS_on_your forehead, Feb 16, 2006
    #8
  9. ishulz

    Samwyse Guest

    it_says_BALLS_on_your forehead wrote:

    > #!/usr/bin/perl
    > use strict; use warnings;
    >
    > my $file = 'aaa';


    So far, so good...

    > -f $file ? print $file, " is a file\n" : print $file, " is NOT a
    > file\n";


    Or maybe this:
    print $file, (-f $file ? "is" : "is not"), " a file\n";

    > system("/usr/bin/ls $file") == 0 or die "$?\n$!\n";
     
    Samwyse, Feb 18, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CwK

    fork

    CwK, Dec 22, 2003, in forum: Perl
    Replies:
    2
    Views:
    941
    Misha Gale
    Jan 4, 2004
  2. Steven D'Aprano

    Why are "broken iterators" broken?

    Steven D'Aprano, Sep 21, 2008, in forum: Python
    Replies:
    8
    Views:
    674
  3. Cameron Simpson

    Re: Why are "broken iterators" broken?

    Cameron Simpson, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    600
    Cameron Simpson
    Sep 22, 2008
  4. Fredrik Lundh

    Re: Why are "broken iterators" broken?

    Fredrik Lundh, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    619
    Fredrik Lundh
    Sep 22, 2008
  5. Eric Snow

    os.fork and pty.fork

    Eric Snow, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    579
    Eric Snow
    Jan 8, 2009
Loading...

Share This Page