6

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

2
  • if you can call your phyton scripts from command line, you can use php exec function. You can construct the parameters in a string then pass it to the exec() function Commented May 23, 2011 at 8:30
  • posible duplicate stackoverflow.com/questions/5697304/… Commented May 23, 2011 at 8:34

2 Answers 2

8

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

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

1 Comment

Can i perform python operation from inside php script rather than going through shell
1

You can call the shell from PHP:

and there are more.

Comments

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.