execute โปรแกรมอื่น

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

จะเขียนโปรแกรมเพื่อให้ execute โปรแกรมอื่น
แล้วเอาผลลัพท์ มาใช้ต่อ ทำไงครับ

sugree's picture

popen ครับ

import popen2, string
 
fin, fout = popen2.popen2("sort")
 
fout.write("foo\n")
fout.write("bar\n")
fout.close()
 
print fin.readline(),
print fin.readline(),
fin.close()

เจอที่ http://effbot.org/librarybook/popen2.htm

ผมใช้

>
from os import popen
 
x = popen('ls')
 
print x
</blockcode>
 
ประมาณนี้ครับ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น