Multiple macdefs in .netrc


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Multiple macdefs in .netrc
# 1  
Old 10-01-2008
Multiple macdefs in .netrc

Hi this is about using .netrc with multiple macro definitions for a single target server. I have seen this done successfully before, but am having trouble getting it working here.

my .netrc file is like the following:

machine server1
login userid1
password userpwd1

macdef ftp_cobol_from_prd
prompt
ascii
lcd /dir1/dir2/
cd /dira/dirb/dirc
mget *.cbl
bye

macdef ftp_logs_from_prd
prompt
ascii
lcd /dirz/dir1/log
cd /dirq/dir1/log
mget *.log
bye

macdef ftp_reports_from_prd
prompt
ascii
lcd /dir1/rpt/prd
cd /dirm/rpt
mget *.rpt
bye

From my shell script I call each macro like this:

echo '$ftp_cobol_from_prd'|ftp server1

Normally I can call each macdef and get it to work fine. I seem to be having issues though. The only macdef that gets executed is the first one no matter which macro I call.
As I said I have seen this work before, I am missing something, though.

Any Ideas?

Thanks!
# 2  
Old 10-03-2008
I got it working. It appears to be related to the length and order of the macdef names. You have to have your macdefs in Alpha order and have the name differences occur in the first 8 characters or so. For example:

macdef ftp_TESTDB_cobol
macdef ftp_TESTDB_txt
macdef ftp_TESTDB_log

would always run the first macdef,

macdef TESTDB_cobol
macdef TESTDB_log
macdef TESTDB_txt

resolves the macdefs correctly.

Just in case anyone is interested.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

4. 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

5. 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

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

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

10. 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