use Sudo; my $su; $su = Sudo->new( { sudo => '/usr/bin/sudo', sudo_args => '...', username => $name, password => $pass, program => '/path/to/binary', program_args => '...', # and for remote execution ... [hostname => 'remote_hostname',] [username => 'remote_username'] } ); $result = $su->sudo_run(); #### sudo_run The sudo_run function first checks the attributes to make sure the minimum required set exists, and then attempts to execute sudo without shell interpolation. You will need to take this into account in case you get confusing failure modes. You may set the debug attribute to 1, 2, or 3 to get progressively more information. The object will return a hash. The hash will have state information within it. If the C'error' key exists, an error occured and you can parse the value to see what the error was. If the run was successful, C'stdout' key exists, and its value corresponds to stdout output from the program run by sudo. Similarly the C'stderr' key will exist for a successful run, and the value corresponds to stderr output from the program run by sudo. The C"rc" key will also be defined with the programs return code. #### foreach my $key (sort keys %result) { print("$key => $result{$key} \n"); }