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.

Sean Francis N. Ballais
2,5082 gold badges28 silver badges44 bronze badges
asked Jul 6, 2016 at 11:45
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.

answered Jul 6, 2016 at 12:58
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.