0

I'm new to phantomjs and I don't know how to use it on linux. The same code that is provided below is working fine on windows but don't know what is wrong with it on linux.
First I just wanna tell you that phantomjs text file and PHP file are in the same folder.

Here is my php file:

<?php
$response =  exec ('phantomjs get.js', $one, $two);
var_dump($response);
?>

Here is get.js

var page = require('webpage').create();
page.settings.loadImages = false;
var fs = require('fs');
var path = 'file.txt';

page.open('http://www.google.com', function () {
page.render('page.png');
var content = page.content;
fs.write(path, content, 'w');
phantom.exit();
});

But there is no response on file.txt and var_dump(). I have a shared hosting plan. Is it due to some permission problems?

6
  • Does phantomjs get.js work when run from the command line? Is phantomjs installed on the Linux host? Commented Aug 20, 2016 at 9:08
  • @jedifans I don't know how to check it on command line. On phantomjs web there was written no need to install just copy. So I did that. Commented Aug 20, 2016 at 9:12
  • @PaulCrovella the same script was working on my windows Commented Aug 20, 2016 at 9:13
  • Do you have SSH access to your site folder? Commented Aug 20, 2016 at 9:15
  • 1
    Try to login via SSH, go to the folder where phantomjs is and do chmod +x phantomjs. Then do phantomjs get.js and see what it will print. if it doesn't work, add any errors to the question. Commented Aug 20, 2016 at 9:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.