RE: [PHP] Re: does this mean ....
popen() opens a named pipe to a program - you can read and write to it if the program you're piping to supports that kind of interactivity (mostly you just read the output from the command). However, in this case, I don't think you want either popen() or fopen() (certainly not fopen() - that just opens a file and that's not at all what you want). You can use a system call or just backticks around the call to useradd (if it's on the same server as your web server). If it's not, you'll have to use sockets and or xmlrpc or some other messaging service. BUT...you probably know that useradd requires root privs. So you either have your webserver running as root (a really really bad idea), or you have it configured to allow suid programs or you have useradd as suid root - also not really good ideas. Maybe you want to take a look at a program called Webmin (http://www.webmin.com/) that already does what you are talking about. I haven't used it for several years, but as I remember, it was a pretty handy tool. ..mike.. On Mon, 2002-07-22 at 17:56, Peter wrote: i'm tring to run the useradd command (under Solaris) to add a user to the system so i don't have to continueously remote log in and also make it easier for myself to add users to the system(s).. maybe popen isn't the best option for this .. though i don't think fopen will be able to do what i need it to do.. maybe playing around with sockets would be better? Cheers Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: does this mean ....
-Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 23 July 2002 10:41 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: does this mean In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... hi all, I'm tring to make a script to prompt for a username then a password = for that user onto the actual machine rather than just a web site... now i've come across this this line in some documentation if ( $File =3D popen( $useradd_prog $useradd_name, r ) ) { . . . now to my actual question .. does that r just mean read? and if so should that r be a w for = write in order for it to work? Cheers=20 Peter=20 the only dumb question is the one that wasn't asked=20 =20 If you are just checking the name/password against an existing list, then you only need read. If you want to add something, then you need a different mode. However, I think you may be better off uing fopen, instead of popen, if you are trying to do what I think you are. The documentation for fopen has a comprehensive description of the modes available; note that w is kindof destructive in the wrong context :-) Cheers -- David Robley Temporary Kiwi! Quod subigo farinam i'm tring to run the useradd command (under Solaris) to add a user to the system so i don't have to continueously remote log in and also make it easier for myself to add users to the system(s).. maybe popen isn't the best option for this .. though i don't think fopen will be able to do what i need it to do.. maybe playing around with sockets would be better? Cheers Peter the only dumb question is the one that wasn't asked -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: does this mean ....
r+ allows you to read and write... if that's what you wanted (I think it is). Note that it will write over any data that is behind the location of the file pointer (so write to the end of the file). Peter [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... -Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 23 July 2002 10:41 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: does this mean In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... hi all, I'm tring to make a script to prompt for a username then a password = for that user onto the actual machine rather than just a web site... now i've come across this this line in some documentation if ( $File =3D popen( $useradd_prog $useradd_name, r ) ) { . . . now to my actual question .. does that r just mean read? and if so should that r be a w for = write in order for it to work? Cheers=20 Peter=20 the only dumb question is the one that wasn't asked=20 =20 If you are just checking the name/password against an existing list, then you only need read. If you want to add something, then you need a different mode. However, I think you may be better off uing fopen, instead of popen, if you are trying to do what I think you are. The documentation for fopen has a comprehensive description of the modes available; note that w is kindof destructive in the wrong context :-) Cheers -- David Robley Temporary Kiwi! Quod subigo farinam i'm tring to run the useradd command (under Solaris) to add a user to the system so i don't have to continueously remote log in and also make it easier for myself to add users to the system(s).. maybe popen isn't the best option for this .. though i don't think fopen will be able to do what i need it to do.. maybe playing around with sockets would be better? Cheers Peter the only dumb question is the one that wasn't asked -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php