Browser unable to open php page?
First of all I am showing the PHP code ....
<?php
echo ("hello");
echo exec("sendip -v -p ipv6 -6s 2001::100 -p tcp -ts 21 -td 21 2001::200 2>
&1");
echo ("hi");
?>
When I entered the command through linux command line it is working fine.The command is sending a tcp ipv6 packet on 2001::200 machine from 2001::100.
[root@udit-pc]# sendip -v -p ipv6 -6s 2001::100 -p tcp -ts 21
-td 21 2001::200 > /dev/null &
/* (-v for verbose) */
Output of above command ...
Added 34 options
Initializing module ipv6
Initializing module tcp
Finalizing module tcp
Finalizing module ipv6
Final packet data:
60 00 00 00 `...
/*
here other packet
contents gets printed
*/
7D 62 00 00 }b..
61 62 63 64 abcd
Sent 64 bytes to 2001::200
Freeing module ipv6
Freeing module tcp
When I execute the php script through command line...
[root@udit-pc]# php test.php
Freeing module tcp
hellohi gets printed and packet arrived at 2001::200.
But problem arise when I try to run php script through browser...
http:://localhost/test.php
hellohi gets printed but packet does not arrive at other machine.
sh: sendip: command not found
Also in both case packet contents are not printed at terminal although using verbose option but when directly using command verbose option works fine.
I tried with many things although I do not think they would help like......
I added /usr/local/lib and usr/local/开发者_如何学Gobin to PATH variable but no benefit.
chmod +s /usr/local/bin/sendip .Sticky bit set but again no benefit.
paste the /usr/local/bin/sendip itself in /var/www/html folder although I have changed the PATH variable but as i said i m just using hit n trial getting no clue.....
There are some output snapshots which may further help ....
[root@cc html]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/usr/X11R6/bin:/root/bin:/usr/local/lib
[root@cc html]# locate sendip
.....
/usr/local/bin/sendip
/usr/local/lib/sendip
.....
[root@cc bin]# chmod +s sendip
[root@cc bin]# ls -l sendip
-rwsrwsrwx 1 apache apache 41071 Sep 26 19:41 sendip
[root@cc bin]# cd /usr/local/lib/
[root@cc lib]# ls -ld sendip
drwxrwxrwx 2 root root 4096 Sep 28 22:48 sendip
[root@cc lib]# chmod +s sendip
[root@cc lib]# ls -ld sendip
drwsrwsrwx 2 root root 4096 Sep 28 22:48 sendip
When file contents are changed .......
<?php
echo exec("/usr/bin/sendip ........ 2 > &1");
?>
Then oputput is :
[root@cc html]# php test.php
Freeing module tcp[root@cc html]#
On browser.... No error gets printed but packet still not arrived.
I am stuck in between.Please suggest me what else should I rather try ??????/
is sendip()
in the path of the shell being invoked by PHP? You're not checking for error conditions, so possibly you're not actually executing sendip, and just getting a "no such program or file" type errors.
Instead of redirecting the exec()'d command's output to null, redirect it all to the browser so you can see what happens:
echo exec("sendiip yada yada yada 2>&1");
Try using the full path:
exec("/usr/lib/sendip -v -p ipv6 -6s 2001::100 -p tcp -ts 21 -td 21 2001::200 > /dev/null &");
The server is most likely not running with the same permissions as the user, you are testing with.
The server is most likely discarding any PATH variable. Make sure that you specify the complete path to sendip
in the exec
call.
The Problem is solved although I can not say its fully solved but as per my need its working.
What i did is I re-installed the sendip ,then I set its sticky bit and then after that I set the Path variable to as above mentioned in question.
Actually the tool is by default installing the libraries in /usr/local/lib/sendip
folder and sendip in /usr/local/bin
folder.
Although after setting PATH variable still I need to use full path in the PHP Script
/usr/local/bin/sendip -v .....
(one of my friend suggested me this..)
What I think is PHP Path is something different from Shell PATH.I need to paste sendip to /usr/bin
and then I need to run updatedb
before setting its sticky bit if I don't want to mention full path in PHP Script .Now this command will work fine in PHP Script.
sendip -v .........
Although May be I am wrong but this all works fine for me.
精彩评论