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

Monks,

I want to write a script that will log me into my vpnc account, but I have to log into an su shell before I can run vpnc. I want to be able to run the script from non su, so I want the script to gain root access and then automatically run and log into vpnc. There is no concern for security.

I have been working with backticks trying to use shell commands such as sudo without results.
From your experience what would be the best way to accomplish this task using perl?

Please point me towards any modules or tutorials that you know of.

Thanks, brahan
  • Comment on Perl scripts that provide login information to applications

Replies are listed 'Best First'.
Re: Perl scripts that provide login information to applications
by almut (Canon) on Feb 05, 2009 at 20:27 UTC

    What exactly were the problems with using sudo? Did you set the "NOPASSWD:" option for the command in question? (Hint: in fact, using sudo would be the preferred solution.)

    As soon as you need to enter credentials, you'll need to use something like Expect, which does fake a terminal, which in turn allows your script to interact with the program on the other side...

      almut,

      I did not see the NOPASSWD option in the man page for sudo but will look again...and also for Expect

      Thanks, brahan

        NOPASSWD is described in the sudoers(5) man page...