Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-23-2011, 11:38 PM
|
#1
|
Member
Registered: Feb 2009
Posts: 98
Rep:
|
php code to change password
hai to all
I have the following php code to print the output in the browser
1) <?php
$one=exec("pwd");
echo $one; //output : /root/docs
$two=exec("ls -l");
echo $two; //output :drwxr-xr-x 9 root root 4096 Apr 3 04:40 .
$three=exec("smbpasswd -a bob");
echo $three; //output : prints some garbage values ..
?>
but when i execute the above code , $three is not working ... I am in a situation to change a password for samba users from php code .... any ideas will help me
Thanks in advance to all
|
|
|
06-24-2011, 01:22 AM
|
#2
|
Senior Member
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
|
first of all, smbpasswd needs to be run as root to add a user or change a different user's password
second, it's an interactive program, that is to say it prompts for input, so executing it in that fassion via php is probably not going to work
|
|
|
06-24-2011, 01:34 AM
|
#3
|
Member
Registered: Feb 2009
Posts: 98
Original Poster
Rep:
|
Thanks for your reply
please suggest me some ideas , to execute this above code in any other fashion ..
|
|
|
06-24-2011, 04:42 AM
|
#4
|
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591
Rep:
|
I don't see what this is good for but you can run php scripts from command line too. Maybe you havte to install php CLI...
Then you can run it as root, or sudo...
another idea, but VERY DANGEROUS:
add the apache user to the sudoers and give him appropiate rights regarding smbpasswd->
man visudo
Last edited by j-ray; 06-24-2011 at 05:09 AM.
|
|
|
All times are GMT -5. The time now is 07:14 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|