Fork broken???

I

ishulz

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?
 
S

sonet

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');
 
I

ishulz

'/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.
 
U

usenet

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?
 
A

Anno Siegel

ishulz said:
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
 
I

it_says_BALLS_on_your forehead

ishulz said:
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?
 
S

Samwyse

it_says_BALLS_on_your forehead said:
#!/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";
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top