0
我的要求是從本地機器掛載遠程服務器上的所有目錄。只有在我以su用戶身份登錄後才能發生掛載。su登錄後需要掛載
下面是我的腳本:
#! /bin/bash
set timeout 20
ip="xx.xx.xxx.xxx"
server_username="root"
server_password="yuyuyuyuyuy"
echo "going to mount the directory with root permission"
CMD1="\[email protected] -a "
VAR2=$(expect -c "
spawn ssh -o StrictHostKeyChecking=no [email protected]$ip $CMD1
match_max 100000
expect \"*?assword:*\"
send -- \"$server_password\r\"
send -- "su"
send -- \"$server_password\r\"
send -- \"\r\"
expect eof
")
echo "===============Done configuration of Server $ip"
但這個劇本似乎並沒有做任何事情。它沒有任何狀態任何錯誤。你能幫我做這個工作嗎?
謝謝!
我懷疑1)意外的奇怪的引用方法和可能的逃避事故的影響和2)你有一堆'發送'命令,沒有介入'期望'語句,這可能會導致一切發送之前有什麼聽... – twalberg