I am running the php script containing Rscript in terminal. its working fine and giving the output. but the same script if i call from the webpage its not giving any output. i have checked the folder permission also. please help me to fix this.
my php script:
<?php
$abc=exec('Rscript dist/GS_R2html.R');
print "$abc\n";
?>
Rscript:
a<-rnorm(1000)
library(R2HTML)
setwd('/var/www/test')
HTML.title("Data Summary", file="dist/gshtml.htm",append=F)
HTML(summary(a),file="dist/gshtml.htm",align="left")
HTML(matrix(a[1:100],nrow=10,byrow=T),file="dist/gshtml.htm",align="left")
HTML.title("Histogram", file="dist/gshtml.htm")
jpeg("dist/plot2.jpg")
hist(a,col="red")
HTMLInsertGraph("dist/plot2.jpg",file="dist/gshtml.htm",Align="left")
dev.off()
Its due to the missing of the rApache which supports web application development using the R and the Apache web server. I followed the steps mentioned in the http://rapache.net/manual.html to install and configure R in Apache.
Related
In my php code:
exec(test.sh);
and test.sh has code:
echo "Hi this is test?" | espeak --stdout > demo.wav
But nothing happen. No error, No output.
If i try to execute test.sh from terminal that it will work perfectly. So why it not run on my php.
Can someone help me?
How do you run your PHP script? With php-cli (in shell mode)? HTTP (Apache, ...)?
It could be a path problem. Could you give us the path of your test.sh, the path of your php script or the URI which is called to run the PHP if you use apache or other HTTP server?
the apache user will need write access to the current working directory (presumably the same directory that contains your php script and test.sh).
I'm playing with Raspberry Pi and anm Arduino shield in order to run a script via Apache/PHP. This script simple blink a LED. I have already tested the script via shell and it works fine, with the command
/root/arduPi/blink_test
I'm able to see my LED blinking. So I made the same thing via Apache PHP with this short PHP script
<?php
if(isset($_GET['cmd'])){
echo '/root/arduPi/'.$_GET['cmd'];
exec('/root/arduPi/'.$_GET['cmd']);
}
?>
but nothing happen and no error has been displayed.
I tested the PHP code with
<?php
phpinfo();
?>
and it's fine. How can I fix this problem?
I had the same issue a while back it was because Apache does not have permission to access certain devices on the Pi. I fixed this by getting rid of the need to be root to access these devices. HERE Is my post about this same issue the fix was to setup sudo as passwordless.
THIS is what I used to accomplish setting up sudo as passwordless. You should then be able to execute the script as follows exec('sudo /root/arduPi/'.$_GET['cmd']);
I have an executable file developed using opencv library in cpp and c also. I want to execute it from my website hosted on localhost using a php script.
The problem i'm facing is that, the executable code opens a window(kind of gui, opened using namedWindow) when called from terminal but it doesn't do that when called from the embedded php script.
For execution i have tried exec, system but all these failed.
to be more clear : name of executable -> my_cv_gui, name of phpscript(page) ->abcd.php
#terminal if i type "./my_cv_gui" ... window opens.
# terminal, if itype "php abcd.php" window opens
abcd.php is part of my website. In web browser if i open "http://...../abcd.php", window DOESNOT open. Although other things in the executable work perfectly.
My system configuration
OS : ubuntu 12.04 x64
XAMPP for Linux 1.7.7
Apache 2.2.21
PHP 5.3.8
Opencv 2.4.1
Any solutions??
The php code is as follows
<?php
$output=shell_exec("gst-launch v4l2src device=/dev/video0 ! 'video/x- raw-yuv,width=640,height=480,framerate=30/1' ! ffenc_flv ! flvmux streamable=true ! queue ! filesink location=/home/dev/my.avi > /dev/null &");
var_dump($output);
?>
Two things you should always remember when you are working with apache.
File/Folder Permission. Using which the apache is running.
MIME type should be added to apache to run any kind of multimedia components. Like here it's flv. Then try running the php code and try fixing it. I will check in my server if that works for me. Will update you.
Biswadip.
I have been trying unsuccessfully so far to write a php script that will run when a page is opened and that will launch metasploit!
I ve tried shell_exec and exec and all the other alternatives but although I can get it to do simple things (i.e. ls, cds etc) if I try msfconsole it doesnt do anything!
I have also tried a different script that launches firefox and again nothing happens!
Now i know that php runs on the server and I m not expecting to see a console or firefox opening in the clients machine! Instead in order to check if it works I am trying to echo out the output of the shell_exec!But anyway since im hosting the files on my machine (i.e. this is the server and a VM is the client) if it could actually launch firefox i should be able to see the app opening here in the same way as by just doing this from the command line!
What am I missing?
Is there any other way to do this?(i.e. Launch metasploit everytime a user opens up my page)
NOTE: I've tried specifying the full path for msfconsole but that didnt work either!
Heres what I have so far:
$output = shell_exec('/opt/local/libexec/metasploit3/msfconsole;show');
echo "<pre>$output</pre>";
The ";show" bit was used in order to actually make it run something and print some stuff but didnt make any difference!
When you run a gui application from the command prompt in a X window system, it will use the default display. When you run it using php which is embedded in apache webserver, the program may not know where to display the gui application.
there are 2 things to make this work.
The program that executes the gui application must have permission to use display
you need to tell the program which display to use.
I used the following in my php script
<?php
$cmd = `export DISPLAY=:0; gedit`;
shell_exec($cmd);
?>
and ran the script from terminal using php -f test.php
I got the gedit up and running.
You can test the same with the script in apache too.
Please add apache user with privileges to access display server
update: I just added the following in /etc/apache2/apache2.conf (I am using ubuntu)
User poomalai
Group poomalai
and restarted the web server
sudo service apache2 restart
now I accessed localhost/test.php
and Presto!! I got the gedit :)
Hope this helps
I am trying to run a php file in my web server in command line using
php test.php
But it is not working. it runs forever and takes 100% resources.
It was working yesterday and now it is not working.
I tried to debug the process using
strace -p <pid>
and got lots of
times(NULL) = -2058427839
Can anyone help me to debug this? Rebooting and upgrading is my last resort. Please suggest a solution without reboot or upgrade.
Try to run your php file in cli without the configuration file using the following command:
php -n <your-filename.php>
and then check whether its working?
Place this into your test.php file to check that it is working and to see what is available.
phpinfo();