Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Exec Fork Trick

by andreychek (Parson)
on Jul 01, 2001 at 21:05 UTC ( #93035=note: print w/replies, xml ) Need Help??


in reply to Re: Exec Fork Trick
in thread Exec Fork Trick

     The big problem is that /bin/passwd uses your TTY instead of STDIN/STDOUT to interact with the user.
This is absolutally true in most versions of passwd. However, some of the more recent versions of passwd provide you with an option to accept input from STDIN. This is the case with passwd that came with RedHat 7.1, and is packaged as version 0.64. It's described in the man page (man passwd), but in short all you have to say is

passwd --stdin

So ginseng, to modify the code you wrote to make use of this, you could do:
# The runtime options to be passed to passwd my $passwd_options = "--stdin"; # All the arguments to be passed to passwd, including name my @args = qw($passwd_options $name); open (PASSWD, "|-") || exec 'passwd', @args; print PASSWD "$password\n$password\n"; close PASSWD;
Again though, remember that you need a recent version of passwd. Just do a 'man passwd' and check to see if the --stdin option exists. Good luck,
-Eric

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://93035]
help
Chatterbox?
[Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.
[Corion]: ambrus: Most of our "automation" is tied to process exit codes and a shell pipeline :-\
[LanX]: ... a week later they realized that one of the databases - which recorded how much the other banks due to this bank - was not correctly plugged
[ambrus]: Corion: I have no problem with exit codes and shell pipeline. My problem is that the current process requires a lot of manual intervention from me, including editing the source codes.
[ambrus]: (Also a lot of manual intervention by two or three other co-workers, who do other parts of the process.)
[ambrus]: Some of the manual part is unavoidable, but not all.
[choroba]: LanX was there a way to recover the numbers from the remaining information?
[Corion]: LanX: Ow ;)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2017-03-29 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.