1 Script Not Sending Password - Other Scripts OK

I am building FTP Script on my Bluehost VPS Server. I have several and all work great except this one.... I think there are two issues .. One with the command and One with "$" in the password.

#!/bin/sh
HOST=invtransfer@52.44.151.220
USER=invtransfer
PASSWORD=XXX$XXX  - $ is real in password.... 
sftp $HOST <<EOF
user $PASSWORD
get INVENTORY.txt
exit
EOF

This is one of the MANY different things I have tried... It connects and asks for the password - if I type it in then it gets the file..
Cannot get it to correctly deliver the password..
Any help would be appreciated... I know is must be something small.

Give it a try as:

PASSWORD='XXX$XXX'

1 Like

I still have to type in the password...

This script .....

HOST=invtransfer@52.44.151.220
USER=invtransfer
PASSWORD='XXX$XXX'
sftp $HOST <<EOF
send $PASSWORD
get INVENTORY.txt
quit
EOF

Does this.. It is sending the correct password format but I still have to type it in.

"Send" doesn't work "user" doesn't work...

[hxisssmy@server ~]$ sh Bell_Daily.sh
Connecting to 52.44.151.220...
invtransfer@52.44.151.220's password:
sftp> send XXX$XXX
Invalid command.
sftp> get INVENTORY.txt
Fetching /INVENTORY.txt to INVENTORY.txt
/INVENTORY.txt                                100%  408KB 408.2KB/s   00:00
sftp> quit

I did not catch that before but you are not using FTP like you said initially. You are using SFTP. It doesn't work like that. It will not read a password from a stream. Either you set it up with a ssh key pair or you have to enter the password interactively.

sftp username@remote_hostname_or_IP
1 Like