2017-05-17 3 views
0

からパイのコードの実行を作るのですか、私が実行したいコードは、Pythonからのパイの上にこのです:はどのように私はPythonの

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0 

私はos.systemまたはsubprocessか何かを使用する必要がありますか?

私が何をしたいの例はここにある:

var1 = self.controller.internet_inet_value.get() 
     var2 = self.controller.internet_mask_value.get() 


var = subprocess.Popen(['sudo', 'ifconfig', 'eth1', '%s' % 
    self.controller.internet_inet_value.get(), 'netmask', '%s' 
    self.controller.internet_mask_value.get()]) 

答えて

0

使用すると、それはより複雑なもの

import subprocess 

var = subprocess.Popen(['sudo', 'ifconfig', 'eth1', self.controller.internet_inet_value.get(), 'netmask', self.controller.internet_mask_value.get()],stdout=subprocess.PIPE) 


output = var.communicate()[0] 
のために好まれるサブプロセス
関連する問題