相关疑难解决方法(0)

从Python运行Expect脚本的最简单方法

我正在尝试指示我的Python安装执行Expect脚本"myexpect.sh":

#!/usr/bin/expect
spawn ssh usr@myip
expect "password:"
send "mypassword\n";
send "./mycommand1\r"
send "./mycommand2\r"
interact
Run Code Online (Sandbox Code Playgroud)

我在Windows上,所以将Expect脚本中的行重写为Python不是一种选择.有什么建议?有没有什么可以像"./myexpect.sh"从bash shell那样运行它?


我在subprocess命令上取得了一些成功:

subprocess.call("myexpect.sh",  shell=True)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

myexpect.sh不是有效的Win32应用程序.

我该如何解决这个问题?

python ssh subprocess expect

8
推荐指数
1
解决办法
4万
查看次数

标签 统计

expect ×1

python ×1

ssh ×1

subprocess ×1