鍍金池/ 問答/Linux/ iterm如何自動登陸到指定目錄

iterm如何自動登陸到指定目錄

目前我是執(zhí)行的這樣一個shell,可以成功免密登錄,但是不能cd到/data/bak/log,求高人指點

#!/usr/bin/expect

set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "[lindex $argv 3]\n"}
        send "cd /data/bak/log\r"
}
interact
回答
編輯回答
誮惜顏

圖片描述

2017年2月1日 13:41
編輯回答
怣人

在send完密碼之后,應(yīng)該expect點東西,不能直接send "cd", 比如等待下命令提示符什么的,否則cd命令會發(fā)送的太早。

2017年7月26日 23:21
編輯回答
汐顏

有誰知道么?還沒有解決

2018年5月7日 16:39