[英]My remote server cannot recognize the variable using sftp in shell scripting
#!/bin/ksh
ysdt=`date -d '-1 day' '+%Y%m%d'`
expect << 'EOS'
spawn sftp id@192.168.61.240:/data01/msc/huawei
expect "Password:"
send "password\n"
expect "sftp>"
send "mkdir $ysdt\n"
expect "sftp>"
send "cd /data01/msc/huawei/$ysdt\n"
expect "sftp>"
send "put /home/med/cdr/bak/hw/mss/prm/$ysdt/b*"
expect "sftp>"
send "bye\n"
EOS
-----error show----------- -----错误显示-----------
can't read "ysdt": no such variable
while executing
"send "mkdir $ysdt\n" "
Your shell isn't expanding the variable ysdt
.您的 shell 没有扩展变量
ysdt
。
If any part of the word passed as delimiter for a here-document is quoted, no expansion occurs.如果引用作为此处文档的分隔符传递的单词的任何部分,则不会发生扩展。 remove the quoting to have expansion occur.
删除引用以进行扩展。
ie IE
expect << EOS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.