如何在调用shell脚本后以编程方式(python)执行终端命令(控件将在shell脚本下)
操作系统:Ubuntu 16.04LTS。 Python自动化 您好,我正在尝试在ubuntu中实现python自动化,在ubuntu中,我必须以编程方式调用shell脚本,在调用shell脚本之后,我需要输入并执行终端命令 我正在使用以下命令调用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 \".
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}”(没有此类文件或目录)。