LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2006, 10:41 PM   #16
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244

Quote:
Originally Posted by aznium
i have no --stdin option

is it possible somehow to do it in C then? call the passwd and change the password?

i can of course write directly to /etc/passwd and /etc/shadow but i want to avoid that and use the passwd command if possible
Its possible, if you can get the source code for passwd.
Change it according to your needs, compile it, name it a different name, eg mypasswd, then call it from your script.
 
Old 09-02-2006, 10:44 PM   #17
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
That would be overkill, interacting with passwd is one of the most common usages of expect.

Just google "expect spawn passwd" and you'll find tons of examples.
 
Old 09-03-2006, 01:37 AM   #18
aznium
Member
 
Registered: Jun 2005
Posts: 36

Original Poster
Rep: Reputation: 15
thx guys

i needed a sleep statement . expect was going too fast?

just for note . heres more code for u guys out there

#!/usr/bin/expect

spawn passwd recoverydaemon
expect "password:"
sleep 1
send "newpassword\r"
sleep 1
expect "password:"
sleep 1
send "newpassword\r"
sleep 1
expect eof
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scripting kb100 Programming 16 08-17-2006 06:41 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Scripting CICA Linux - General 7 10-03-2005 10:36 AM
Need some scripting help Askari Programming 1 11-26-2003 10:25 AM
scripting help wedgeworth Linux - Software 10 09-25-2003 01:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration