473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

running shell_exec commands as root


I've a PHP script that is run as a cron job. It contains this line:

$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
The lsof command returns almost nothing unless you are the root user.
Can anyone think of a way I can use su or sudo or something else to get
this script to run as root?

(And yes, I'm aware that it is dangerous to allow a PHP script to run as
root, but it is in an otherwise secure environment, far removed from the
web.)
Jul 11 '08 #1
3 5845

Lawrence Krubner schreef:
>
I've a PHP script that is run as a cron job. It contains this line:

$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
The lsof command returns almost nothing unless you are the root user.
Can anyone think of a way I can use su or sudo or something else to get
this script to run as root?

(And yes, I'm aware that it is dangerous to allow a PHP script to run as
root, but it is in an otherwise secure environment, far removed from the
web.)
Hi,

The easiest way is to make a cronjob for root.
Just go root and crontab it.

If you have no rootaccess, you cannot run as root of course....

Regards,
Erwin Moller
Jul 11 '08 #2
On Jul 11, 4:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
LawrenceKrubnerschreef:
I've a PHP script that is run as a cron job. It contains this line:
$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
The lsof command returns almost nothing unless you are the root user.
Can anyone think of a way I can use su or sudo or something else to get
this script to run as root?
(And yes, I'm aware that it is dangerous to allow a PHP script to run as
root, but it is in an otherwise secure environment, far removed from the
web.)

Hi,

The easiest way is to make a cronjob for root.
Just go root and crontab it.

If you have no rootaccess, you cannot run as root of course....

That is what I tried first. I logged in as root and did "crontab -e".
But the script doesn't seem to run as root. The lsof in the script
seems to run as... I don't know who. It returns no data, which would
make sense for a non-root user.

Jul 19 '08 #3
lawrence k schreef:
On Jul 11, 4:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
>LawrenceKrubnerschreef:
>>I've a PHP script that is run as a cron job. It contains this line:
$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
The lsof command returns almost nothing unless you are the root user.
Can anyone think of a way I can use su or sudo or something else to get
this script to run as root?
(And yes, I'm aware that it is dangerous to allow a PHP script to run as
root, but it is in an otherwise secure environment, far removed from the
web.)
Hi,

The easiest way is to make a cronjob for root.
Just go root and crontab it.

If you have no rootaccess, you cannot run as root of course....


That is what I tried first. I logged in as root and did "crontab -e".
But the script doesn't seem to run as root. The lsof in the script
seems to run as... I don't know who. It returns no data, which would
make sense for a non-root user.
Hi,

Roor user should be able to run that command just fine.
Are you sure you simply don't have a process named 'vsftpd'?
What does this produce:
$stringListingAllProcesses = shell_exec("lsof");

Also nothing???

Regards,
Erwin Moller
Jul 23 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sandman | last post by:
In another post I told about PHP not being able to create dates earlier than 1970, so until I can get PHP to do so, I am using a small perlscript to do it. It looks like this: // $in is...
8
by: Good Man | last post by:
Hi there If I enter the following at the command line, I successfully get an email sent to the correct name/email: php /var/www/html/admin/adminscripts/welcome-cli.php 'Me' 'me@me.net'
0
by: Will Seay | last post by:
At the end of this message I've pasted a script we're trying to modify slightly. I don't believe it is VBscript or javascript but these are the closest groups I could find with my limited...
1
by: Patrick L. Nolan | last post by:
We have a Tkinter application which has a menubar with cascade submenus. I would like to start the program with one of the submenu items state=DISABLED, then change it to state=NORMAL at a later...
0
by: paulhjwu | last post by:
Hi, I have problems running a couple of shell scripts from PHP. I found a similar posting, so I posted my question to the original author. But unfortunately the original author is not at the...
6
by: jonathan.beckett | last post by:
Hi all, We have PHP 4 installed on Windows 2003 with Apache 2, and the shell_exec has mysteriously stopped working - it hangs the page rather then returning anything. To check it out, I tried...
0
by: Don | last post by:
Hi, I have a problem with the special characters on the function shell_exec (under Linux Debian with php 4.3.10-16): $msg = '"'."Léà t'es où?".'"'; $output = shell_exec('java myClass'.'...
2
by: tanyali | last post by:
I am using Linux Suse10, php 5 . execute a shell script in a terminal, it works. output is a file with data . when I use it in php like this (code : php) : chdir("../file");...
5
by: scorpionbilli | last post by:
Hi, The local mysql server is running on my Macbook. I can access it through the console client: $ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.