Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在调用shell脚本后以编程方式(python)执行终端命令(控件将在shell脚本下)_Python_Shell_Terminal_Ubuntu 16.04 - Fatal编程技术网

如何在调用shell脚本后以编程方式(python)执行终端命令(控件将在shell脚本下)

如何在调用shell脚本后以编程方式(python)执行终端命令(控件将在shell脚本下),python,shell,terminal,ubuntu-16.04,Python,Shell,Terminal,Ubuntu 16.04,操作系统:Ubuntu 16.04LTS。 Python自动化 您好,我正在尝试在ubuntu中实现python自动化,在ubuntu中,我必须以编程方式调用shell脚本,在调用shell脚本之后,我需要输入并执行终端命令 我正在使用以下命令调用shell脚本 import os os.system("gnome-terminal --working-directory='/home/murlee/CTS/android-cts/tools' -e 'bash -c \".

操作系统:Ubuntu 16.04LTS。 Python自动化

您好,我正在尝试在ubuntu中实现python自动化,在ubuntu中,我必须以编程方式调用shell脚本,在调用shell脚本之后,我需要输入并执行终端命令

我正在使用以下命令调用shell脚本

import os
os.system("gnome-terminal --working-directory='/home/murlee/CTS/android-cts/tools' -e 'bash -c \"./cts-tradefed; exec bash\"'")
*现在,我需要在调用shell脚本后输入和执行终端命令的帮助

调用shell脚本后,我的终端将如下所示

"murlee@murlee-Lenovo-ideapad-100-14IBD:~/CTS/android CTS/tools$ /cts tradefed

安卓CTS 6.0R17版本:3866870

cts tf>(这里我必须输入命令并执行)


谢谢

创建一个名为
my init.sh

./cts-tradefed
现在打电话

import os
wd  = '/home/murlee/CTS/android-cts/tools'
cmd = "bash --init-file {0}".format('./my-init.sh')
os.system("gnome-terminal --working-directory='{0}' -e '{1}'").format(wd,cmd)

你能告诉我一些关于my-init.sh的细节吗。我试着喜欢你的答案,但是我不知道在哪里保存my-init.sh文件。请同时检查我的错误和my-init.sh命令。#/bin/bash$SCRIPT_PATH=“/home/murali/CTS/android CTS/tools/CTS tradefed.sh”exec“$SCRIPT_PATH”,错误:-为该终端创建子进程时出错,未能执行子进程“{1}”(没有此类文件或目录)。