Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-03-2005, 12:36 AM   #1
Registered: Nov 2004
Location: shanghai
Distribution: worket
Posts: 41

Rep: Reputation: 15
Arrow how to invoke passwd

i know i will invoke "system(ls)" and list all file information.
and i not know how to invoke "system(passwd)"?who may explian it to me?

how to slove it ?
Old 06-03-2005, 12:50 AM   #2
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
first of all, system command doesnt work with interactive commands like passwd.
System executes a command by calling "/bin/sh". So when you call
system (passwd), a new shell is created and "passwd" command is called. It is now
waiting for the inputs of old and new passwords. The calling program will hang.

Use Expect scripts, may be for these tasks.

Any how, programatically setting a password is not a good option.
Old 06-03-2005, 02:44 AM   #3
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
if you really need to call sys() , you may try this :

system("xterm +hold -e 'passwd'");
but this will gives you an xterm ...
this works on my linux though


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
vim invoke noir911 Programming 1 01-29-2005 07:15 PM
invoke xterm through program sudha naidu Programming 2 12-27-2004 03:46 AM
invoke makefile: make invasian Linux - Newbie 2 08-08-2004 01:52 AM
Want to invoke debugger through JSP. kirti Programming 0 06-11-2004 02:30 AM
How to invoke FTP from Korn shell WindozBytes Programming 6 09-07-2002 08:53 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:48 PM.

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