Ahmed Moustafa <[EMAIL PROTECTED]> wrote:
[ That address is bouncing, by the way. ]
It should not! What was the message that you got?
How can I switch user "su" in perl?
It's much easier to do that before running the script. :-)
$ su -c ./script.pl
And then once you're root, you can change the real and effective user ids with the magic $< and $> variables.
From inside a non-privileged Perl script, the only thing you can do is re-exec the script via su/sudo and punch in the password.
#!/usr/bin/perl -l
exec "sudo", "/usr/bin/perl", $0, @ARGV if $<;
print " uid: ", getpwuid $<; print "euid: ", getpwuid $>;
If you need to run disconnected from the terminal, you should just put the script in the correct user's crontab.
Would you tell me more about the crontab, please?
But you could also use Expect.pm to automate password entry, or configure sudo not to ask for the password.
What I need to do is to add a PGP public key to a user's key ring. Which approach would you recommend?
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]