FTP script

Hi,

I want a small help . my requirement is to write a script which will make a FTP connection to one server ( called a.a.a.a) and gets file from there and print all the logs in one file .

I wrote it long back but noe can not recall.
thanks

Search this site for ftp scripts. And if you've written a script once, you can definitely write it again. Do *not* expect to just sit back and have other people write scripts for you.

Here is one thread for ftp script.
Ftp Script
if you face any issue get back to us.

I am seeing the below problem

Connected to 10.114.106.167.
220 (vsFTPd 1.2.0)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.114.106.167:rishir):

while my code is as below
#!/bin/bash
SERVER=10.114.106.167
USER=abc
PASSWD=abc

ftp $SERVER
user $USER $PASSWD
mkdir PPL
hash
bin
put ftp.sh
bye

ftp.sh = one script which I want to put on the destination server .

Could you please help me on this.

#!/bin/bash
SERVER=10.114.106.167
USER=abc 
PASSWD=abc 

ftp -in $SERVER<<EOF
user $USER $PASSWD
mkdir PPL
cd /path of remote dir
lcd /path of local dir
hash
bin
put ftp.sh
bye
<<EOF

Thank Q , its working fine.

Hi all, i followed the thread and modified the discussed solution.
My purpose is to ftp 2 files from a remote server to a local directory. Is my code below correct? i can't try it now because i do not have access to my servers yet.
would appreciate if anyone can let me know if there is any problem with my code.

SERVER=222.444.333.00
USER=abc 
PASSWD=abc 

ftp -in $SERVER<<EOF
user $USER $PASSWD
cd /path of remote dir where file resides
lcd /path of local dir where i want the file to be
text 
get target.file1
get target.file2
bye
#!/bin/bash
SERVER=10.114.106.167
USER=abc 
PASSWD=abc 

ftp -in $SERVER<<EOF
user $USER $PASSWD
cd /path of remote dir
lcd /path of local dir
hash
bin
get targetfile1
get targetfile2
bye
<<EOF

here "bin " means we want to ftp in binary mode if you want to do in ascii then replace bin with ascii.
if you want to ftp with script from unix to windows then you need to make a search in forum if ftp is unix to unix then it should work fine.

Hi Dhruva,

is it necessary to use hash?

and my file are in text format, if i use the bin command, will my file in the local directory end up in 1's and 0's ?

No it wont be in 0s and 1s.If files are in text format then better use ascii.To be more precise "ascii" is default format so you can omit that one too.hash is not necessary to use.you remove that.

Hi Dhruva,

thanks for the prompt reply and advise.

Hi all,

i've written my script and i am facing the same problem as the OP. my script is

USER=abc
    PSWD=xyz
    FTP_STAT=ftp.txt
    cat > $FTP_STAT <<MOO
    open aaa.bbb.ccc.ddd
    user $USER $PSWD
    get $remote_file $localfile
    bye
MOO

The error message i got is " Please login with USER and PASS.
Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Login incorrect.
Login failed.
Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
Please login with USER and PASS.
ftp: bind: Address already in use"
The file does not get transferred over. Any advise?