Operating System - Linux
1826325 Members
3515 Online
109692 Solutions
New Discussion

Help needed!!! Perl went for nuts

 
SOLVED
Go to solution
Igor I. Shulz
Frequent Advisor

Help needed!!! Perl went for nuts

I have a server HPUX 11.11 which keeps many perl scripts running (perl 5.8). This night I had to reboot it and after rebooting I found that many of the scripts don't work. It strange - it seems that fork from perl script is broken. This is test fragments:

This is simple prog:

#!/usr/bin/perl -w
system('/usr/bin/ls 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?
14 REPLIES 14
Arunvijai_4
Honored Contributor
Solution

Re: Help needed!!! Perl went for nuts

Hello,

can you put the script under perl debgger and see what happens there ? Something like,

#perl -d tmp.pl

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(tmp.pl:2): system('/usr/bin/ls aaa >bbb');
DB<1>

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

:-((

# perl -d a.pl

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(a.pl:2): system('/usr/bin/ls aaa >/tty');
DB<1> n
main::(a.pl:3): print $!,"\n", $?, "\n";
DB<1> p $?
65280
DB<2> p $!
No such file or directory
DB<3>
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

Sorry:

# perl -d a.pl

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(a.pl:2): system('/usr/bin/ls aaa >bbb');
DB<1> n
main::(a.pl:3): print $!,"\n", $?, "\n";
DB<1> p $?
65280
DB<2> p $!
No such file or directory
DB<3>
H.Merijn Brand (procura
Honored Contributor

Re: Help needed!!! Perl went for nuts

what is the pwd in that script? is it allowed to write/create bbb?

what happens when you open bbb yourself?

open BBB, "> bbb" or die "Cannot write to bbb: $!\n";
close BBB;
system ("ls aaa > bbb") or die "ls failed: $!";

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

open BBB works fine

system - no. File bbb is empty after system ("ls aaa > bbb") or die "ls failed: $!";

die doesn't executed because system returns 65280.

# perl -d a.pl

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(a.pl:10): system ("ls aaa > bbb") or die "ls failed: $!";
DB<1> n
main::(a.pl:12): 0;
DB<1> p $?
65280
DB<2> p $!
No such file or directory
DB<3>
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

system - no. File bbb not exists after system ("ls aaa > bbb") or die "ls failed: $!";
Muthukumar_5
Honored Contributor

Re: Help needed!!! Perl went for nuts

Try as,

# cat test.pl
#!/usr/bin/perl -w
`/usr/bin/ls muthu > /err.log`;

# perl -d test.pl
DB<1> n

what you are getting now?

--
Muthu
Easy to suggest when don't know about the problem!
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

# perl -d b.pl

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(b.pl:2): `/usr/bin/ls muthu > /err.log`;
DB<1> n
main::(b.pl:3): 1;
DB<1> p $?
256
DB<2> p $!

DB<3>


/err.log - is not created
Muthukumar_5
Honored Contributor

Re: Help needed!!! Perl went for nuts

Try as,

# cat test.pl
#!/usr/bin/perl -w
`/usr/bin/ls muthu > /err.log`;

# perl -W test.pl

what you are getting?

--
Muthu
Easy to suggest when don't know about the problem!
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

# perl -W test.pl
#

err.log is not created
Arunvijai_4
Honored Contributor

Re: Help needed!!! Perl went for nuts

Just a thought, Reinstalling perl may help...

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Help needed!!! Perl went for nuts

Try like,

# cat > test.pl
#!/usr/bin/perl -w
`/usr/bin/ls muthu > /err.log 2>&1`;

# perl test.pl
# cat /err.log

what you are getting. I feel it is a problem with STDERR (2 File descriptor) setup.

--
Muthu
Easy to suggest when don't know about the problem!
Igor I. Shulz
Frequent Advisor

Re: Help needed!!! Perl went for nuts

Case closed.

It seems that during of reboot /bin (symlink to /usr/bin) was removed (fsck?)

After recreating symlink all orks fine !!!

Thank to all.
Arunvijai_4
Honored Contributor

Re: Help needed!!! Perl went for nuts

http://forums1.itrc.hp.com/service/forums/helptips.do?#28
"A ship in the harbor is safe, but that is not what ships are built for"