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

Hello Monks, my first time here.

I am trying to make a Perl sript in Linux that, besides other things, mounts a network filesystem. Basically, the problem is that I don't know how to interact with bash when it prompts for the password, after the mount call inside Perl:

my @output = `mount //xpto /xpto2 -o username=xpto3`

Well, I know that the password could be passed as an option of the mount call, but let me just say that this can't be done in this specific case.

Any ideas? Is there any Perl module that could help solving that?

Thanks a lot!

Zeca

Replies are listed 'Best First'.
Re: Help with mount!
by mr_mischief (Monsignor) on Mar 13, 2009 at 18:08 UTC
    You may be interested in Expect. It's a tool to interact with a program on a TTY based what you expect to be output and what you want to provide as input.

      Thanks to mr_mischief. Expect (in fact Expect::Simple) really did the trick!

      Thank you all for the other tips.

      Zeca

Re: Help with mount!
by slacker (Friar) on Mar 13, 2009 at 19:49 UTC
    In addition to what ig said, this link provides detailed documentation to do exactly what was described.
    mounting with password
Re: Help with mount!
by ig (Vicar) on Mar 13, 2009 at 19:17 UTC

    As an alternative to interacting with bash at runtime or providing the password as an argument to the mount command, you may be able to put the authentication credentials in a secure file and have the mount command read them from there.

    How and whether you can do this will depend on your file system type. For example, with a CIFS filesystem (mount.cifs) you can either provide the credentials option to specify a file containing the username and password or set the PASSWD_FILE environment variable to specify a file containing the password.