Operating System - HP-UX
1754415 Members
2898 Online
108813 Solutions
New Discussion юеВ

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

 
SOLVED
Go to solution
Hamdy Al-Sebaey
Regular Advisor

Automation of FTP (to James Ferguson & the rest of Collegae)

Hi James,
I've read your answer & the answer's of our collegae about how to configure Auto. FTP but I need your help;
Mijn question is that:
I would like to transfer files through FTP from one server in our company to another server in another company, what did I do as following:
suppose I 've serverA ( at my company), server B (at the other company)
1-I created a user call John (on my server), who is gonig to log in from the other server to get files through ftp.
2-I created a file .netrc in which I put the following
(IP) 1.2.3.4
(login) John
(password) al5678
macdef init
cd /target_dir (for example /tmp on the other server)
lcd /source_dir (for example /tmp/John on my server
promt
mget*
quit
**********************************
I tried many times from the other company server to FTP with John, I did'nt get nothing,
once I moved .netrc onder /home, once onder /home/John. Noway.
- Do I miss somethig?
- If so would you like kindly to explain this to me?

Thanks alot
Hamdy
Thanks for sharing knowledge
8 REPLIES 8
Pal Szabo_1
Valued Contributor

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

I think you used a wrong syntax.You should use machine
codeword not the (IP)
The example netrc file:

machine venus login anonymous@123.17.57.66 password root@ macdef init
open 123.17.57.66
bin
lcd /oracle7/fixdist/fddb
get /x/fixes/v4/xx.tar tar.Z
quit
James R. Ferguson
Acclaimed Contributor
Solution

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Hi:

Based on you example, your .netrc file should look like this:

------
machine 1.2.3.4
login john
password al5678
macdef init
cd /target_dir
lcd /source_dir
prompt
mget*
quit

------

Note carefully the zero-length line after the 'quit' in the 'init' macro.

...JRF...
Hamdy Al-Sebaey
Regular Advisor

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Firstly, thanks alot for Pal& James.
James what you mean with your (Note carefully the zero-length line after the 'quit' in the 'init' macro)?.
Thanks,
Thanks for sharing knowledge
James R. Ferguson
Acclaimed Contributor

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Hi:

By a "zero-length" line I mean "an empty line (consecutive newline characters)".

...JRF...
Hamdy Al-Sebaey
Regular Advisor

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Hi James,
Thanks alot for your suggestion.
everything is running wel.
Have anice day
Hamdy
Thanks for sharing knowledge

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Try create a script file transfer.sh on Server B

:transfer.sh
#
ftp -n<<+++
open 1.2.3.4
user John al5678
cd /target_dir
lcd /source_dir
prompt
mget*
quit
+++

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

One very good method is the following:

%ftp -n 11.11.11.11 user whatshisname
password typepassword
bin
get /remotedir/file /localdir/file
bye

This file will always run then you can just change the files you need. Run the above script fromt he machine where you want the file to go or change the get to put.
hilo
Shannon Petry
Honored Contributor

Re: Automation of FTP (to James Ferguson & the rest of Collegae)

Myself, I prefer the .netrc file method for automating FTP. I'm probably fooling myself, but I feel like I have more control.......That being said, here is one not very known rule for the netrc file. It MUST have 0400 permissions on it! If there is 0700, 0640, 0644, etc.... It not be used. If it has 0600 permissions on it, it will be used, but the system will complain about it. Of course it HAS to be owned by the user, and in their home directory as defined in /etc/passwd or nis passwd file/database.

The easiest way to test a netrc file is to su - user, and ftp to the host defined in the .netrc file. If all is good, it should echo all things done in the .netrc init macro. :) Easy to test!

Regards,
Shannon
Microsoft. When do you want a virus today?