Click here to get back home

using bare perl to run Unix passwd

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
using bare perl to run Unix passwd smcracraft 02-04-2008
Posted by smcracraft on February 4, 2008, 10:42 pm
Please log in for more thread options
Hi,

Anyone know of a Perl program that can
run Unix passwd and set a particular password
for a particular user?

I don't want to have to edit the passwd or shadow
files and want to use the built-in-passwd.

The two caveats on this is: no Expect allowed and
also no Perl libraries other than the standard ones.

Also, this is not on Windows but on Unix.

Thanks anybody/everybody.

Posted by Pat Deegan on February 5, 2008, 12:12 am
Please log in for more thread options
Greets,

On Mon, 04 Feb 2008 19:42:38 -0800, smcracraft wrote:

> Hi,
>
> Anyone know of a Perl program that can run Unix passwd and set a
> particular password for a particular user?

On my system at least, `passwd` has a --stdin option:
        "This option is used to indicate that passwd should
        read the new password from standard input,
        which can be a pipe."

So opening a pipe to '| passwd --stdin username' should work.

HTH,
Pat D

Posted by smcracraft on February 5, 2008, 12:53 am
Please log in for more thread options
passwd does not have a --stdin on most vendor Unixes because
it is considered a security flaw.

I should have been more specific to exclude the above "--stdin"
from the requirement.

> Greets,
>
> On Mon, 04 Feb 2008 19:42:38 -0800,smcracraftwrote:
> > Hi,
>
> > Anyone know of aPerlprogram that can run Unix passwd and set a
> > particular password for a particular user?
>
> On my system at least, `passwd` has a --stdin option:
> "This option is used to indicate that passwd should
> read the new password from standard input,
> which can be a pipe."
>
> So opening a pipe to '| passwd --stdin username' should work.
>
> HTH,
> Pat D


Posted by John W. Krahn on February 5, 2008, 1:15 am
Please log in for more thread options
smcracraft wrote:
>
> Anyone know of a Perl program that can
> run Unix passwd and set a particular password
> for a particular user?
>
> I don't want to have to edit the passwd or shadow
> files and want to use the built-in-passwd.
>
> The two caveats on this is: no Expect allowed and
> also no Perl libraries other than the standard ones.
>
> Also, this is not on Windows but on Unix.

http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/3de7596861d102be/39fa3c167101fcae?lnk=st&q=#39fa3c167101fcae


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Similar ThreadsPosted
bare underscore? March 26, 2008, 7:54 pm
using passwd in a perl script July 13, 2005, 12:27 pm
Re: username passwd expect September 14, 2006, 4:07 am
Checking user's in passwd file August 5, 2007, 10:54 am
rename userid in passwd, shadow, group August 2, 2005, 12:07 pm
Unix BG and Perl/TK October 22, 2007, 7:05 pm
MacPerl vs. Unix (OS X) Perl July 11, 2004, 11:53 pm
Unix commands and perl November 28, 2004, 3:45 pm
Perl interface to Unix ps? December 23, 2004, 3:24 pm
how could i get perl module in unix? January 13, 2005, 7:42 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap