Password Pipe
Wally Strzelec
packman at tamuts.tamu.edu
Wed Mar 27 04:50:09 AEST 1991
Howdy.... I am writing a short program that will allow me to change the
password on a remote machine. To do this I am trying to use popen and
feed it the "/etc/passwd" command on the remote machine. The problem
is that it seems that the passwd command doesn't accept anything that
I send down the pipe. Can someone please tell me where I am messing
up. The following is my test:
#include <stdio.h>
main (argc, argv)
int argc; char *argv[];
{
char line[25], pass[9], user[9];
FILE *pi, *popen();
strcpy(user, argv[1]);
strcpy(pass, argv[2]);
printf("%s %s\n", user, pass);
sprintf(line, "/bin/passwd %s ", user);
pi = popen(line, "w");
if(!pi) {
exit(1);
}
fprintf(pi, "%s\n", pass);
fprintf(pi, "%s\n", pass);
pclose(pi);
exit(0);
}
Thanks....
Wally Strzelec
Texas A&M University
Unix System Administrator
packman at tamuts.tamu.edu
These are my own opinions and do not necessarily reflect those of
Texas A&M University.
More information about the Comp.unix.wizards
mailing list