Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Fork broken???

Reply
Thread Tools

Fork broken???

 
 
ishulz
Guest
Posts: n/a
 
      02-16-2006
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?

 
Reply With Quote
 
 
 
 
sonet
Guest
Posts: n/a
 
      02-16-2006
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" <(E-Mail Removed)> ???
news:(E-Mail Removed) ups.com ???...
> 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?
>



 
Reply With Quote
 
 
 
 
ishulz
Guest
Posts: n/a
 
      02-16-2006
The same ((

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      02-16-2006
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

 
Reply With Quote
 
ishulz
Guest
Posts: n/a
 
      02-16-2006
'/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.

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      02-16-2006
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

 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      02-16-2006
ishulz <(E-Mail Removed)> 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.
 
Reply With Quote
 
it_says_BALLS_on_your forehead
Guest
Posts: n/a
 
      02-16-2006

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?

 
Reply With Quote
 
Samwyse
Guest
Posts: n/a
 
      02-18-2006
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";

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.fork and pty.fork Eric Snow Python 0 01-08-2009 06:32 AM
Noob help request on TCP Server with fork xchris Perl 5 06-22-2004 11:56 AM
Can't fork exec from webpage, problem is not permissions Patrick Perl 1 05-14-2004 12:03 PM
fork in perl 5.8.3 on windows Josh Denny Perl 2 03-02-2004 11:24 PM
fork CwK Perl 2 01-04-2004 04:13 PM



Advertisments