Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How to enter password through a file when it prompts on STDOUT.

by sagarkha (Acolyte)
on Aug 18, 2010 at 10:29 UTC ( #855733=perlquestion: print w/ replies, xml ) Need Help??
sagarkha has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am trying to mount a Windows Share to my RHEL 4 machine using this script
system("mount -t smbfs -o username=sachins,domain=POWERSOFT,password= +***** //172.28.89.164/PS /mnt/test");
But after execution it always prompt for the password again.
[root@innovation scripts]# ./moun.pl Password:
Is there a way i can save password in a file or in array and use it whenever it prompts.

Comment on How to enter password through a file when it prompts on STDOUT.
Select or Download Code
Re: How to enter passowrd through a file when it prompts on STDOUT.
by shmem (Canon) on Aug 18, 2010 at 11:07 UTC

    Maybe you should use the parameter password, not passowrd.

    But generally speaking, you don't use system if you want to feed something into a spawned command's STDIN - you use open $fh, "|-", "$program @args"; - you are out of luck, though, if a program reads directly from /dev/tty (e.g. /usr/bin/passwd).

      Your not completely out of luck if it reads from the controlling tty directly but you will require stronger magic, such as Expect or IPC::Run which will run things on a pty.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Re: How to enter passowrd through a file when it prompts on STDOUT.
by wazoox (Prior) on Aug 18, 2010 at 11:08 UTC
    Well it looks like you mistyped the "password" keyword, so...
Re: How to enter password through a file when it prompts on STDOUT.
by ww (Bishop) on Aug 18, 2010 at 14:37 UTC
    sagarkha
    It's discourteous -- at best, and this may be such a case -- to amend something you've posted without including a notice to that effect.

    So, since you didn't, here's a notice:

    Parent node's spelling error (noted by respondents above) was corrected without notice by OP
    "<node id="855733" title="How to enter passowrd through a file when it prompts on STDOUT."
    and
    "system("mount -t smbfs -o  username=sachins,domain=POWERSOFT,passowrd=*****  //172.28.89.164/PS /mnt/test");"

Re: How to enter password through a file when it prompts on STDOUT.
by robrt (Novice) on Aug 20, 2010 at 09:46 UTC

    hey.. I too had experienced this kinda prob some time back... I dont exactly remember the syntax, but you can try adding the username and password of your windows machine into your linux machine, so that it never again asks for the pwd.

    Here is the procedure(google it if not correct)

    Login into RHEL machine as root, type the following commands:

    useradd -a <username of windows>

    <you would be prompter for the windows machine password>

    <enter the pwd again>

    Now run your script. Thats it... probably this might solve your prob.
      Its working for me now, thnx.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://855733]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2014-09-21 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls