Jump to content


Photo

how to execute python files


  • Please log in to reply
3 replies to this topic

#1 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 10 July 2006 - 08:25 PM

Yo,

I need a little help over there.. I wanna to run a python script from a php page.. something like:
/* block code */
switch ( $var ) 
{
   case 1:
      # run first.py
   case 2:
      # run second.py
}
/* block code */
This is just an exemple from my idea..

Thanks anyway.

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)

#2 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 10 July 2006 - 08:34 PM

Maybe something like:
$result = shell_exec('script1.py');

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#3 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 11 July 2006 - 06:23 PM

hm, its don't work.. i've tried it this logic:

print '1'
shell_exec
print '3'

the py file is togheter in the same folder, so i use the $result as you said, but, it print '1', and stop printing.. do nothing..

tonight i will try better, now im little busy, but thanks =)

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)

#4 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 12 July 2006 - 12:16 AM

Try putting whatever you would put on the command line into a shell_exec because I don't know much about executing python.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users