Hello, I have a bash script used to telnet and transfer files which works great. Trying to FTP to a box that does not support telnet. Been told to use ssh to the user@someIPaddress. I can log in manually but can't seem to make this script work. And help would be appreciated.
#!/bin/bash
HOST=ssh user@x.x.x.x
USER=user
PASSWD=passwd
cd /home/
chmod 700 *
list_file=` file`
ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd /home/somedir
binary
put $list_file
bye
!x
exit 0
The script is not getting past the login negotiations part.
220 xxxx FTP server ready.
331 Password required for xxxx.
530 Login incorrect.
Login failed.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
(local-file) (remote-file) 221 Goodbye.
I can manually login so I know the username and password are good. Strange one.
---------- Post updated at 05:35 PM ---------- Previous update was at 05:31 PM ----------
This part of the script puts the file
put $list_file
Here is the whole script though
#!/bin/bash
HOST=scp file user@x.x.x.x
USER=user
#PASSWD=passwd
cd /home/somedir
list_file=` .csv`
ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd /somedir/
binary
put $list_file
bye
!x
exit 0
So your HOST variable is scp file user@x.x.x.x which after the assignment is done sets HOST to scp .
Your PASSWRD is commented out: #PASSWD=passwd .
I think there're a couple (at least) things that needs to be fixed first.
ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd /home/somedir
binary
put $list_file
bye
!x
This is your man ftp ("linux") command. The red line tries to open an FTP connection to $HOST. Regardless of what you put in there, it's going to try and use FTP protocol (and in this case will fail since what you have is not a valid host name). You can't just put scp or ssh in there to use SSH.
Leave the 'user@host1' out if you are copying local files onto host2. It will try to copy a file named 'user@host1' and complain that such a file does not exist.