编写python代码来从终端进行调用?

时间:2017-05-29 20:47:35

标签: python

我试图在ubuntu的终端上编写一个运行以下命令的程序:

" xselect @ nameofscript"

我正在调试使用此代码执行专长的代码:

def runXSelect(scriptname):

    '''This function will automatically run any xselect script input.
    It returns the stdout. Since it does not natively overwrite 
    existing pha files, in FileHelper, the write script will handle 
    this'''

    cmd = "xselect @ " + scriptname
    args = shlex.split(cmd)
    out = ""
    with subprocess.Popen(args, stdout=subprocess.PIPE,
                          universal_newlines=True,shell=True) as proc:


        proc.wait()
        out = proc.stdout.read()

    return out

我从stdout获得的错误是:

@: 1: @: xselect: not found

如果我只是在终端上键入命令,它运行正常。但是关于代码的一些事情导致执行失败。

有什么建议吗?

0 个答案:

没有答案