in reply to Re^2: perl and sudo basic question
in thread perl and sudo basic question

On line 27 %$result should be %{ $result }.

Update: Dang, johngg is right. I didn't know %$ dereferenced a hash -- I've always done it the %{$href} way. Thanks for the heads up and sorry for any confusion!

Replies are listed 'Best First'.
Re^4: perl and sudo basic question
by johngg (Canon) on Jul 10, 2007 at 09:21 UTC
    On line 27 %$result should be %{ $result }.

    Why?

    $ perl -le ' > $h = {a => 1, b => 2}; > print for sort keys %$h;' a b $

    Cheers,

    JohnGG

      I don't know how it happened, but the Sudo.pm is wrong, this code is wrong :
      %ret = { 'error' => (sprintf 'Error: the sudo binary "%s" is not set t +o group id = 0',$sudo) }; return \%ret;
      So I changed manually the code to return the correct info like this:
      $ret = { 'error' => (sprintf 'Error: the sudo binary "%s" is not set t +o group id = 0',$sudo) }; return $ret;
      Now it is giving me the correct error information. But the actual script seems to be not running. Here is the test.sh file info :
      echo hello echo something >> /tmp/testfile
      I haven't seen hello in the display OR the file /tmp/testfile has not been created. The "result" code is 256, what does it mean.

        I haven't seen hello in the display OR the file /tmp/testfile has not been created. The "result" code is 256, what does it mean.
        Normaly you would do my $realexitcode = $exitcode >> 8;, assuming that Sudo.pm uses system to execute sudo -- in this case this is 1. Looking into sudos man-page:
        RETURN VALUES Upon successful execution of a program, the return value from sudo will simply be the return value of the program that was executed. Otherwise, sudo quits with an exit value of 1 if there is a configuration/permission problem or if sudo cannot execute the given command.

        regards,
        tomte


        An intellectual is someone whose mind watches itself.
        -- Albert Camus