linux 帐号便捷登陆
核心
如设置便捷su
#!/usr/bin/expect -f set port port_no set user st_mchri_bigdata set password Genomics20210 set timeout -1 spawn su $user expect "*assword:*" send "$password\r" interact
便捷ssh登陆帐号
#! /usr/bin/expect # set your login information set user lizhichao set ipaddress 192.168.6 set passwd li #get the verfication code from local host set code [exec sh -c {curl -s "http://localhost:17304"|grep -Eo "\d{6}"}] #Golden passport for verfication set timeout -1 #login, request password and vertification code spawn ssh lizhichao@192.168.6 expect "*assword:*" send "$passwd\r" expect "*erification code:*" send "$code\r" interact
核心函数
set 设置shell
spawn 执行命令
本文来自博客园,作者:BioinformaticsMaster,转载请注明原文链接:https://www.cnblogs.com/koujiaodahan/p/15831142.html
posted on 2022-01-21 17:35 BioinformaticsMaster 阅读(48) 评论(0) 编辑 收藏 举报