psimonovsk has asked for the wisdom of the Perl Monks concerning the following question:

I have meat very strange phenomenon... Platform - RH 5.2(i386) Perl version - 5.8.7 and 5.8.4 ( I have tried 2 distributions... One (5.8.7 installed on machine with RH OS installation, and second - 5.8.4 I have installed in user's local directory) In few words - "use" of Net::Domain module cause "system" function call to fail (with any command) Let us say code:
use strict; use Net::Domain; my $rc=system("/bin/ls"); print rc, "\n";
prints - 13 Of cause - if I run from command line /bin/ls - it works... More interesting! If I run same script as root user - it works properly! But, only if I run it as root... If I run it as any other user - it prints "13" If I comment out use Net::Domain; - everything works with any user ... I am totally lost! Do any one have an idea - what can be a reason for such strange mess???

Replies are listed 'Best First'.
Re: Net::Domain module works only as root
by ikegami (Patriarch) on Jan 07, 2010 at 21:44 UTC

    As documented in system, that means ls was successfully launched, but died from signal 13. (thundergnat is mistaken.) On my system, that's SIGPIPE. (Check kill -l) Do you somehow redirect the output of the script?

      Hi guys! First of all - thanks for replies... It is just mistake in cut and paste... In code it is $rc... any way - I also see - that command fails (xterm do not open) an , when I run it as root - it works... An no - I do not use any redirection - it is just test script with 4 lines of code... Of cause problem appeared in much more complicated program, but I succeed to isolate it on 4 lines example... It also do not matter - what is a command, xterm or ls , or something else...

        Since I wasn't explicit earlier, the code works perfectly fine for me when the missing $ is added. Sorry, I have no ideas.

        Perl 5.8.8, Net::Domain 2.20.

Re: Net::Domain module works only as root
by thundergnat (Deacon) on Jan 07, 2010 at 21:02 UTC

    You are missing the $ sigil on $rc... Not that that is your problem.

    You are not running the script with sufficient permissions. 13 is the return error code from the system call. Error number 13 is "Permission denied". (Under linux)

    Update: Sigh, I am indeed wrong as ikegami points out below. Error number 13 is "Permission denied" under Windows. That being said, maybe the missing sigil IS your problem... writing to an undefined handle perhaps?

      Update: Sigh, I am indeed wrong as ikegami points out below. Error number 13 is "Permission denied" under Windows.

      That's not what I said. I said system returning 13 means the child died from SIGPIPE. It does not mean Permission denied on any OS.

      Now, if system returned -1, then you'd check $!, and if $! then contained 13, that would mean that system failed because of a permission error (on Windows and linux). But system did not return -1, which means the child was executed successfully. Neither system nor ls reported a permission errors.