duanjiao3686
duanjiao3686
2013-06-20 19:35

PHP执行时,Python SSH脚本不起作用

  • python
  • php

I have a Python (2.7) script that connect to a remote device through SSH and configure it. This script works fine when I run it.

I have a PHP page that execute other Python scripts and they are also working fine. The problem: the SSH script doesn't work when I'm running it from the PHP page. (there is no problem with the PHP page nor the Python script)

To be more specific, the script (when executed by PHP) is running until it gets to the first SSH related code (import paramiko).

How can it be, and is there anything I can do to make it work? Thanks!

(OS: windows XP. Server:Wamp (Apachi http server)

for example, consider this simple code:

fp=open("file.txt","w")
fp.write("text")
import paramiko
fp.write("another text")
fp.close()

if executed by me, everything works fine. If by the PHP page- only the code until "import paramiko" is executed.

or:

fp=open("file.txt","w")
fp.close()
import paramiko
fp2=open("file2.txt","w")
fp2.close()

Executed by me- both files created. by php- only the first.

Moreover: I tried using Try & Catch but nothing comes up. No exception is thrown.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答