0

I have a Python file, which is an automation script from GitHub. I want that script to be executed by a PHP page.

For example, I have an index.php page, and it has a button saying Start script. Upon clicking the button, a Python script, instabot.py, should be executed. Is this possible in cPanel? My web host is Hostgator.

1
  • you can use ftp to copy your .py file to your host. Commented Jul 6, 2016 at 12:52

1 Answer 1

0

Using information from another StackOverflow post, you might wanna use exec() to run a Python script from PHP. Like:

exec('python /path/to/file/instabot.py');

According to Hostgator's documentation, Python scripts should have permissions set at 755.

Uploading your Python scripts will be the same as uploading any file to a web host, through the use of FTP or cPanel itself.

Sign up to request clarification or add additional context in comments.

2 Comments

What if I need to print the output of file in php page. ?
@HannanMustajab You're welcome. You might wanna click the check mark next to this question. As for printing the output, instead of exec(), use shell_exec(). So to print the output, do, $output = shell_exec(...); echo $output;.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.