Exec python from php -


i'm trying run python script php with

$res = ''; exec('./home/desktop/scripts/fetch_matches.py', $res); 

my python file starts #!/usr/bin/python , has exec rights. have print in there it's not working(var_dump($res) gets me empty array). what's missing?

also, if i'll have different methods in script, how call them?

you need rid of . before path. if it's normal unix/linux system, /home in root of filesystem. . means current directory, unless you've recreated /home filesystem in directory you're running php program, path incorrect. also, unless username desktop, you're missing directory between /home/ , desktop/ - should username. pwd command never return . before present working directory.

for second question, please refer docs on calling python command line. can execute arbitrary code command line, along lines of

python -c "from fetch_matches import fetcher; fetcher()" 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -