I need to SFTP a file to a server. The password has a dollar sign $
and I need to escape it.
I tried with Perl and sed commands I am able to replace but the string following $
is not getting added.
Example:
echo "Np4$g" | perl -pe 's/$/\\\\\$/g'
output
Np4\\$
It supposed to be Np4\\$g
, but g
is not getting appended.
Code:
/usr/bin/expect <<EOF
set timeout -1
spawn sftp -C -oPort=$port $sftp_username@$host_name
expect "password:"
send "$password\r"
expect "sftp>"
cd $remote_dir
send "mput *.txt\r"
expect "sftp>"
send