phpnewbie007 Posted November 23, 2014 Share Posted November 23, 2014 I am trying call an R batch file inside php script from browser. The R script basically generate an imgae and save in a folder. Unfortunately, I could call the R within php (means that no image is saved in the folder) using BROWSER. But when I run the php script from the commadline, it works and image is saved in the folder. <?php exec("Rscript /var/www/html/phil/figs/map.R"); ?> Execuition of following R batch code and php codes work and save image in the specified folder from the terminal. 58A-UD3R:~$ php /var/www/html/phil/x.php 58A-UD3R:~$ Rscript /var/www/html/phil/figs/map.R I totally in confusion why browser cannot successfully save image. Or is there anythinng need to be change in server for generating image? Anyone please help me for solving this probelm. Thank You.. Quote Link to comment https://forums.phpfreaks.com/topic/292652-r-code-execution-from-php-fails-only-in-browser-and-not-in-terminal/ Share on other sites More sharing options...
NotionCommotion Posted November 23, 2014 Share Posted November 23, 2014 Just to confirm, http://yourdomain.com/phil/x.php is the small PHP script you are showing, right? Maybe read/write privileges? What does the following give you? <?php echo ('Current script owner: ' . get_current_user().'</br>'); echo(exec("Rscript /var/www/html/phil/figs/map.R").'</br>'); shell_echo(exec("Rscript /var/www/html/phil/figs/map.R").'</br>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/292652-r-code-execution-from-php-fails-only-in-browser-and-not-in-terminal/#findComment-1497372 Share on other sites More sharing options...
phpnewbie007 Posted November 24, 2014 Author Share Posted November 24, 2014 I run with your test php file and it only displayed the user in browser (ie, Current script owner: 'myusername'). But not generated image in the folder. But when I run the same file from terminal, it generated image. I have an HTML form and onclcik a button calls the x.php (which in turn expected to generate and save image). I call the file from url as 'http://localhost/phil/main.html'. So is that a problem with permission? Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/292652-r-code-execution-from-php-fails-only-in-browser-and-not-in-terminal/#findComment-1497450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.