Shell_exec is not working


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Shell_exec is not working
# 1  
Old 09-15-2019
Shell_exec is not working

I am trying to execute a command with shell_exec but this command does not work, other commands work

Code:
<?php
    $output = shell_exec("tail /var/log/syslog");
    echo "<pre>$output</pre>";
    ?>

# 2  
Old 09-16-2019
Please execute and post the error from your PHP error.log file.

When we code in PHP, we always run a tail on the PHP error.log file so we can see errors as the occur.
This User Gave Thanks to Neo For This Post:
# 3  
Old 09-20-2019
Code:
[Fri Sep 20 16:29:05.960464 2019] [mpm_prefork:notice] [pid 1090] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Fri Sep 20 16:29:05.960506 2019] [core:notice] [pid 1090] AH00094: Command line: '/usr/sbin/apache2'
tail: cannot open '/var/log/syslog' for reading: Permission denied

# 4  
Old 09-20-2019
So...?
This User Gave Thanks to RudiC For This Post:
# 5  
Old 09-22-2019
Quote:
Originally Posted by Rodrigo_Bueno
Code:
[Fri Sep 20 16:29:05.960464 2019] [mpm_prefork:notice] [pid 1090] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Fri Sep 20 16:29:05.960506 2019] [core:notice] [pid 1090] AH00094: Command line: '/usr/sbin/apache2'
tail: cannot open '/var/log/syslog' for reading: Permission denied

So, it pretty obvious that since your core PHP process cannot read /var/log/syslog; hence the basic problem is not shell_exec, the problem is that this file is not readable by your LAMP server process.

Please execute these commands:

Code:
ls -l /var/log/syslog

and also

Code:
ps aux | grep -i apache | tail -10

... and cut-and-paste the results (using our code tags) into your reply.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Disk Space Utilization in HTML format working in one environment and not working on the other

Hi Team, I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system. df -h | awk -v host=`hostname` ' BEGIN { print "<table border="4"... (13 Replies)
Discussion started by: Harihsun
13 Replies

2. Shell Programming and Scripting

Automating pbrun /bin/su not working, whenever manually it is working using putty

I am trying to automate a script where I need to use pbrun /bin/su but for some reason it is not passing thru the pbrun as my code below. . ~/.bash_profile pbrun /bin/su - content c h 1 hpsvn up file path I am executing this from an external .sh file that is pointing to this scripts file... (14 Replies)
Discussion started by: jorgejac
14 Replies

3. Shell Programming and Scripting

Sqlplus with shell_exec(); PHP command

Hi, I need to run a PL/SQL Query from a distant oracle server in order to create spool files and send it to my own server, using a php script. I firstly created a SH script called myscript.sh #!/bin/bash echo "This script is working" sqlplus... (8 Replies)
Discussion started by: cgstag
8 Replies

4. Web Development

php shell_exec

Hey guys i've recently been getting into php programming and i became thinking was it possible to create a php script that would allow you to run a terminal from the browser page? All i've pretty much got so far is: $var = $_GET; $output = php shell_exec($var); echo $output; ... (4 Replies)
Discussion started by: lordfirex
4 Replies

5. Shell Programming and Scripting

Passing array variable in shell_exec

Hi all, i wrote a php script in which i passed some values in the array variable using a for loop. I have to pass this array values to a shell script using shell_exec() <?php while($row = mysql_fetch_assoc($ansid)) { //$row = mysql_fetch_assoc($ansid); $aid = $row; echo $aid; $i =... (2 Replies)
Discussion started by: vidhyaS
2 Replies

6. Shell Programming and Scripting

c binary not being executed with shell_exec()

I have written a c program. And compiled it to make a binary. Now when i try to call this binary from php page, it is not being executed. [ (2 Replies)
Discussion started by: xerox
2 Replies

7. Web Development

trouble with shell_exec()

If you aren't familiar with LaTeX, don't stress.. it's just a document markup language that I use for creating Math documents. Anyway, if I execute "latex /home/destructo/Desktop/example.tex" inside my command prompt (ubuntu), it will create the desired document... I decided to try to create a... (3 Replies)
Discussion started by: tyrick
3 Replies

8. Programming

Calling macro in shell_exec not working

Hi guys! I really need your help. I have a php code that should convert doc, ppt,etc. to pdf using openoffice. But its not working, and im not sure what the problem is. Here's my php code: define('OOFFICE_LIBRARY', '/usr/lib/openoffice.org/program/'); $convertToPdf = OOFFICE_LIBRARY .... (5 Replies)
Discussion started by: tweine
5 Replies

9. Shell Programming and Scripting

Help with PHP and shell_exec!!!

Hi, I've been working on a PHP script which is "supposed" to find an individuals weather based on their geolocation. This script uses "shell_exec". I have checked my syntax and it is correct, but there is still something missing; for when I call on the script using: <form action='/weather.php'... (15 Replies)
Discussion started by: o0110o
15 Replies

10. Shell Programming and Scripting

php shell_exec, exec command timeout

HI, Does anybody know if its possible to execute a command through exec, shell exec, system and if the program doesn't terminate in N seconds returns control to PHP ? reg, research3 ---------- Post updated 10-16-09 at 12:20 AM ---------- Previous update was 10-15-09 at 11:03 PM... (1 Reply)
Discussion started by: research3
1 Replies
Login or Register to Ask a Question