I want to build a php based site that (automate) some commands on my Ubuntu Server
first thing I did was going to the file (sudoers) and add the user www-data so I can execute php commands with root privileges!
# running the web apps with root power!!! www-data ALL=(ALL) NOPASSWD: ALL
then my PHP code was
<?php $command = "cat /etc/passwd | cut -d\":\" -f1"; echo 'running the command: <b>'.$command."</b><br />"; echo exec($command); ?>
it returns only one user (the last user) !!! how to make it return all users?
How do I benefit from argc and argv in C++, the standard way? [closed]
1:get an ioctl file descriptor for ethernet port
Return Values. Is it possible to wrap calls to statically linked 3rd party library? The last line from the result of the command. Is there STDCALL in Linux?If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. howto check a network devices status in C? To receive the output of the executed command, be sure to set and use the output parameter.. Problems with system() calls in LinuxSo you have to did any thing similar to this:. How do I use mqueue in a c program on a Linux based system?
<?php $output = array(); $command = "cat /etc/passwd | cut -d\":\" -f1"; echo 'running the command: <b>'.$command."</b><br />"; exec($command, &$output); echo implode("<br />\n", $output); ?>