Jump to content

Recommended Posts

Hi,

my probelm is that i have full access to the shell of the server (fedora 3.1) but running this code in a php file on xampp server that i have on the same server , i am not getting the output even when i am trying to pipe the output to an html file .

<code>

 

shell_exec("cat `find ./logs -name access.log*` | grep akadi_icho | ./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html>akadi_icho.html");

 

</code>

but when i am running this code on the shell directly :

<code>

cat `find ./logs -name access.log*` | grep akadi_icho| ./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html>akadi_icho.html

</code>

it is working perfectly.

so i have tried to run the code in parts :

<code>

shell_exec("cat `find ./logs -name access.log*` | grep akadi_icho");

</code>

this part is working, but when i am running the whole part i am not getting any output.

 

so plz can u help me to figure out the problem.

 

Link to comment
https://forums.phpfreaks.com/topic/62631-solved-shell_exec-problems/
Share on other sites

Hi again , i appreciate ur help, i have used system() function in two ways:

$last_line = system( shell_exec('cat `find ./logs -name access.log*`|grep $userid |./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html'), $retval);
echo $retval;

the output was:

Warning: system() [function.system]: Cannot execute a blank command in /opt/lampp/htdocs/xampp/thesis/traffic.php on line 28

where line 28 is the system command by it self.

 

the second way :

$last_line = system('cat `find ./logs -name access.log*`|grep $userid |./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html', $retval);
echo $retval;

 

the output was :

126

 

related to the combining STDERR with STDOUT i dont know the right syntax if u can give me an example that i can figure out how to use it

 

i have used system() function in two ways:

 

The first is incorrect, the second is correct.

 

Since you're using single quotes $userid will not be interpolated. If double quotes don't fix the problem, try running pwd to make sure you're in the right directory.

 

related to the combining STDERR with STDOUT i dont know the right syntax if u can give me an example that i can figure out how to use it

 

<pre>
<?php
### This won't show you anything because it only returns STDOUT.
echo shell_exec('notacmd');

echo '<hr>';

### This will show the error because it returns STDOUT and STDERR.
echo shell_exec('notacmd 2>&1');
?>
</pre>

finally i could find the solution which is : in php code i couldn't run a perl script without calling the perl or bash to run it , so i have done that in the following way:

<code>

echo shell_exec("cat /opt/lampp/htdocs/xampp/thesis/logs/access.log.* | grep $userid | /usr/bin/perl  ./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html");

</code>

thanx buddy

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.