|Perl: the Markov chain saw|
Exec Fork Trickby ginseng (Pilgrim)
|on Jul 01, 2001 at 15:38 UTC||Need Help??|
ginseng has asked for the
wisdom of the Perl Monks concerning the following question:
I wrote a program not too long ago that needed to run another program and slurp up the output. I used something I believe is called an "Exec Fork", like this:
I'm assuming that I can do that in reverse, sending output from my script as input to the foreign program. Specifically, I'm trying to run passwd, as root, from a perl script.
My code looks like
and it does launch passwd, but still prompts for the new password at the console, interactively. The script doesn't seem to be printing to it.
I assume I'm doing something wrong. Can you see what it is?
Before I get a (probably deserved) "don't reinvent the wheel; use X" response, I did find and try Unix::PasswdFiles, but it didn't seem to work with the shadow file on my OpenBSD installation. In fact, it replaced the entire file with the one line it was adding. That would have been very scary if I hadn't backed up first. I decided it was safer to use the supplied program...if I can get it to work. I'm still open to alternative suggestions, but I didn't want you to think I was ignoring all of the work that's come before me ;)