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