I have a requirement where i will do sftp to a different server and i want to do this by a shell script
But the password is having asterisk(*) character, so unable to log in. Script :
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/
Error info :
Unknown command `*B6L'.
cd: Login failed: Login incorrect
Please help me out. Thanks in advance
The problem is &
(ampersand). Replace
user $user $passwd
with
user $user "$passwd"