我想添加命令的输出
cat /data/ftproot/file
到下面的期望脚本。我目前的尝试导致了期望中的问题
can't read "(cat /data/ftproot/file)": no such variable
我的尝试在下面。有没有一种方法可以使期望值进入输出
/usr/bin/expect << 'EOF'
set timeout -1
spawn ssh user@HOST
expect {
"*assword: "
}
send "s3cretpass\r"
expect {
"*]# "
}
send {ls -tr /data/ddp/ | grep DDP | tail -1 | awk -F- '{print $2}' | awk -F. '{print $1 "." $2 "." $3}' > /data/ftproot/file}
send "\r"
expect {
"*]# "
}
send "cat /data/ftproot/file \r"
expect {
"*]# "
}
send 'mv /data/ftproot/DDP-SNAPSHOT.tar.gz "/data/ftproot/DDP-$(cat /data/ftproot/file)-SNAPSHOT.tar.gz" \r'
expect {
"*]# "
}
EOF