Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by sagarkha (Acolyte)
on Aug 18, 2010 at 10:29 UTC ( [id://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.

Replies are listed 'Best First'.
Re: How to enter passowrd through a file when it prompts on STDOUT.
by shmem (Chancellor) 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 (Archbishop) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-24 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found