ubuntu使用ssh远程登陆操作ubuntu

 
使用以下代码检测expect是否已经安装

ls /usr/bin | grep expect

如果显示为空,则使用以下命令安装

sudo apt-get install tcl tk expect


以下是示例脚本
#! /usr/bin/expect
spawn ssh crrc@192.168.10.192
expect "*password:"
send "abc.1234.2020 "
expect "*#"
send "cd wal "
expect "*#"
send " mkdir test "
expect "*#"
interact
 









原文地址:https://www.cnblogs.com/wal1317-59/p/12773823.html