.netrc question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting .netrc question
# 1  
Old 02-25-2005
.netrc question

Hi, id like to ask a question about .netrc. Id like to have 2 entries for a particular machine, but with different ftp userid's ie

Code:
machine 172.19.8.26 login dcm password dcm
macdef job1
bin
hash
bye

machine 172.19.8.26 login ppp password ppp
macdef job2
bin
hash
bye

this code DOES NOT WORK by the way !!!

normally i reference a "macdef" by its name to have multiple jobs running under the same machine/ftp user, but i have now come accross the scenario where i need to run jobs from different ftp accounts on the same box,

can anybody help ? Smilie
# 2  
Old 02-25-2005
It might matter on your OS - I couldn't get some to work either in testing.

Try the following:

Code:
machine 172.19.8.26 login dcm password dcm
macdef init
bin
hash
bye

machine 172.19.8.26 login ppp password ppp
macdef init
bin
hash
bye

# 3  
Old 02-25-2005
Quote:
normally i reference a "macdef" by its name to have multiple jobs running under the same machine/ftp user, but i have now come accross the scenario where i need to run jobs from different ftp accounts on the same box,

You do n't want to have two different .netrc files
one for each account ?
# 4  
Old 03-07-2005
Quote:
You do n't want to have two different .netrc files
one for each account ?
these arent unix user accounts they are accounts on the remote FTP server, all my scripts run from a single unix account called "scripts_user" and therefore i only have one .netrc file. I do not want to have to run the script from a different unix account just because I have 2 different FTP accounts on the same remote FTP server

any ideas ???
# 5  
Old 03-07-2005
Quote:
Originally Posted by RTM
It might matter on your OS - I couldn't get some to work either in testing.

Try the following:

Code:
machine 172.19.8.26 login dcm password dcm
macdef init
bin
hash
bye

machine 172.19.8.26 login ppp password ppp
macdef init
bin
hash
bye

ok, i dont understand ow you would call this from a script ???
# 6  
Old 03-07-2005
Quote:
ok, i dont understand ow you would call this from a script ???
You don't call it from a script - it's automatic when you are running ftp. If you run the ftp command from a script to a machine in the list (in the .netrc file), then it should automatically run those commands. Set up your .netrc with a system you want to go to via ftp, put in some non-harmful commands such as ls, bin, and dir, ftp to the server and see if it runs those commands. If it does, try actually sending a file via a command in the .netrc. Try both of these via manual and cron. Once you see how it works, then put in what you need for production.
# 7  
Old 03-07-2005
Quote:
Originally Posted by RTM
You don't call it from a script - it's automatic when you are running ftp. If you run the ftp command from a script to a machine in the list (in the .netrc file), then it should automatically run those commands. Set up your .netrc with a system you want to go to via ftp, put in some non-harmful commands such as ls, bin, and dir, ftp to the server and see if it runs those commands. If it does, try actually sending a file via a command in the .netrc. Try both of these via manual and cron. Once you see how it works, then put in what you need for production.
sorry, I dont think you undestand my question..I use .netrc for hundreds of scripts to many ftp servers. but with your suggestion, you have placed 2 entries for the same machine next to each other in the same .netrc file but with different ftp username and password . So based on this ,when you issue your ftp command (manually or from a script, it doesnt matter) ie `ftp 172.19.9.100` then it has to make a decision on what entry in .netrc to use , so how does it determine which username/password to login as ????? this is my question. When you have multple jobs on the same FTP server (all using a single ftp username and password) i use the macdef parameter to tell .netrc which job to run...but that is not applicable in this case

Last edited by hcclnoodles; 03-07-2005 at 12:06 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Help with macdef (.netrc)

Am trying a shell script for ftp process on Solaris I am trying to mget files to Destination server: myserverxxx1 folder : /backup/dumps/SERVER-1backup/afterbatch From Source server: SERVER-1 folder : /dumps/daily/backupafterbatch/Thu21Oct_04:22:37 depending on the date the... (1 Reply)
Discussion started by: sunnyboy
1 Replies

3. IP Networking

Can I use 2 different id's in .netrc for same dest. machine.

I have 2 different id's for an ftp destination. Each id handles files differently on the destinations end. Is it possible to have one destination machine and assign an alias name for each id. The .netrc file doesn't allow this. (2 Replies)
Discussion started by: wangotango
2 Replies

4. Red Hat

Netrc for Linux

What is the proper format for configuring the netrc file for linux. On Solaris it was: Machine <machinename> login Domain\\login password passwordname (1 Reply)
Discussion started by: soupbone38
1 Replies

5. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: DeepakS
3 Replies

6. AIX

.netrc and ftp

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

7. UNIX for Advanced & Expert Users

using .netrc

Hi friends, Can we use the file .netrc for automating ftp from a perl script ? and if so then how do i go about it ? can i have a sample script for this ? thanks in advance Veera (6 Replies)
Discussion started by: sveera
6 Replies

8. UNIX for Dummies Questions & Answers

.netrc file

I had configured the .netrc file for automatic login to ftp however i am not clear how to give the port no after the "machine" token: as in, when i give machine xyz.com 2121 login <usid> password <pass> i am getting the error Unknown .netrc keyword 2121 while giving the command ftp xyz.com... (1 Reply)
Discussion started by: jithinravi
1 Replies

9. UNIX for Dummies Questions & Answers

.netrc file

hello, I am trying to write an automated script to transfer multiple files to another solaris 5.8 box. I am using the #! /bin/bash prompt and I am having trouble finding/creating the .netrc login file. I googled and the only info I got was that I should create/find it in my home directory. I went... (2 Replies)
Discussion started by: grandtheftander
2 Replies

10. UNIX for Dummies Questions & Answers

Help in .netrc

Hi, I would like to ask if the .netrc file should really be stored/placed in the /home/<userid> directory or in the home directory indicated by the uinfo command? I am currently having problems with a .netrc file which is owned by a id which has it's home directory pointed to a... (2 Replies)
Discussion started by: edu_escandor
2 Replies
Login or Register to Ask a Question