Automating ftp without .netrc

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automating ftp without .netrc
# 1  
Old 08-16-2009
Automating ftp without .netrc

I'm writing a script which needs to run under an 'automation' account and there is already a .netrc machine definition for the server I need to connect to.

If I create a new machine entry in the .netrc with a different account this will, of course, be ignored and the ftp session will connect to the incorrect account. Also, I don't have access to perl's Net::Ftp.

Any tips on how I should proceed?
# 2  
Old 08-16-2009
Knowing the source O/S would help. Anyway, Perl excluded, SFTP exclude, and talking in general about most unixes

FTP client looks for ${HOME}/.netrc

After login has completed the environment variable $HOME does not have to refer to a real home directory. In your script, you can change and export $HOME prior to starting ftp. Thus you can have as many .netrc files as you so desire in directories of your choice. Each file should still have permissions 600 and be owned by root or the specific ftp user.

Another approach is to have multiple names for the same FTP server IP address in /etc/hosts , and then to refer to each name in the common .netrc file .
# 3  
Old 08-16-2009
Use an expect(1) script, an example is at:
Using ActiveState Expect For Windows
admittedly this is for expect for Windows but it won't be very different for Unix.
# 4  
Old 08-16-2009
Modifying the $HOME variable worked out.

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Specifying port for ftp when using .netrc

Hi, does anybody know if it is possible to specify a particular port for an FTP address within a .netrc file ? i have a script which opens the ftp to a machine and then instigates .netrc to login etc.. within .netrc i need it to go to a particular port to enable me to automate the dropping of... (2 Replies)
Discussion started by: forefather1977
2 Replies

2. Shell Programming and Scripting

Doubt in .netrc file for ftp login

Hi, i have a doubt. i am using .netrc file for login to a ftp server. ftp suppose i have 2 userid and password for the same server as shown below. which one is it going to read from the .netrc file? cat .netrc machine login admin1 password pass1 machine... (13 Replies)
Discussion started by: Little
13 Replies

3. UNIX for Dummies Questions & Answers

Performing Batch ftp without .netrc

How can I supply the userID/password when executing FTP in the batch mode? Using .netrc is not an option (prohibited per Corporate Policy). Thank you in advance. (1 Reply)
Discussion started by: compaamat
1 Replies

4. AIX

.netrc and Automatic ftp problem

Guy's We have two AIX servers Server1 and Server2 and we have created user1 in Server1 and Server2 ... and .netrc file was confiured under /home/user1 with the below line machine server2 login user1 password abc1234567 -rw------- 1 user1 staff 159 Sep 28 2004 .netrc ... (7 Replies)
Discussion started by: ITHelper
7 Replies

5. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host= /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

6. Shell Programming and Scripting


So... I'm trying to script and FTP Backup of some files from openVMS Alpha machine to a Unixware 7 machine. I decided to use .netrc to do all the FTP actions however when I send the nmap command. It pretty much gets ignored while even other things such "ascii", "case" etc.. get respected... (0 Replies)
Discussion started by: thesubmitter
0 Replies

7. AIX

.netrc and ftp

Hello all, I am using a .netrc to automatically access an ftp host. Here is the line I use... machine login nw\mylogin password ******* when I use this command... ftp I get... Connected to 220 server_7 FTP server (EMC-SNAS: (4 Replies)
Discussion started by: magikalpnoi
4 Replies

8. UNIX for Dummies Questions & Answers

.netrc and ftp issue

Ok guys (gals?) Im new here as a member, but have come here many times to find answers to questions. Have played with Unix (ATT Sys 5) and now Linux (RH)... I told myself I wanst going to ask for help on the current project..but.. I am down to what I think is the last issue: (and I KNOW the... (3 Replies)
Discussion started by: txdave
3 Replies

9. UNIX for Dummies Questions & Answers

.netrc multiple ftp jobs to same machine

I have an ftp user, which has been setup to run ftp jobs to a specific machine (different jobs). for the first job i created .netrc in the ftp users home directory and added the appropriate commands machine FTPBOX01 login user1 password xxx macdef init etc etc get file bye I use the... (3 Replies)
Discussion started by: hcclnoodles
3 Replies
Login or Register to Ask a Question