Mosquito
Mosquito

Reputation: 181

Can I call python script or function from php

I have the php page which lists the backups with filename and username. the backups are done with python script but for web interface I used php.

Now I want to put the facility on webpage where there will be button called restore next to backup file name and all the home dir contents are replaced.

I can make the python function with parameters like backup filename , username and it restores the backup.

But I don't know how can I pass variables to python via php

Upvotes: 6

Views: 19603

Answers (2)

Rudie
Rudie

Reputation: 53851

You can call the shell from PHP:

and there are more.

Upvotes: 1

Vikram
Vikram

Reputation: 7515

Yes you can call exec("python pythonscript.py someparams"); or if you need to save the output to a variable use this code

exec("python mypythonscript.py someparams",$output);
var_dump($output);

More informaiton: call python script by php and solve errors

Upvotes: 8

Related Questions