bash - 密码中的星号字符 - 登录失败

标签 bash shell scripting sftp

我有一个要求,我将 sftp 到不同的服务器,我想通过 shell 脚本来完成

但是密码有星号(*)字符,所以无法登录。 脚本:

host=xxxxx
user=celcom_mnp
passwd='CjX3E$4Q&*B6L'
cd /home/mquser/unicaftp/CMS/batch/OBD/MNP/
test=`find . -maxdepth 1 -type f -name "*.csv" -mmin +1 | awk -F "/" '{print $NF}'`
lftp<<EOF
open sftp://$host
user  $user $passwd
cd /MNP_Autoin
lcd  /home/mquser/unicaftp/CMS/batch/OBD/MNP
mput `echo $test`
EOF
OUT=$?
if [ $OUT -eq 0 ];then
   echo "$test Succesfully transferred" >> /home/mquser/CIFM_STORE/OBD/obdmnplog.txt
else
   echo "Issue with sftp" >> /home/mquser/CIFM_STORE/CEP/PUSH/sftplog.txt
fi
mv $test /home/mquser/CIFM_STORE/OBD/TEMPMNP/

错误信息:

Unknown command `*B6L'.
cd: Login failed: Login incorrect

请帮帮我。提前致谢

最佳答案

问题是 &(与号)。替换

user  $user $passwd

user  $user "$passwd"

关于bash - 密码中的星号字符 - 登录失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34170954/

相关文章:

linux - 如果比较特定字符串时条件不匹配,则 Bash

Bash shell 脚本 : how do I exit and restart the script?

linux - 连接硬编码目录和用户创建的文本文件会在不应该的时候添加根级路径

bash - 在没有 nc 的情况下获取 memcached 统计信息很热吗?

linux - 如何在 bash 中以特定字符串作为排序键对文件进行排序?

python - 如何让python和linux shell交互?

linux - 如果 grep 找到匹配项,则打印 grep 关键字

c# - 带有脚本的Unity音频错误

linux - Linux 中 applescript 的替代品是什么?它们有何不同?

bash - Git远程推送: failed to load advapi32. dll