The $HOME/.netrc file contains information used by the automatic login feature of the rexec and ftp commands. It is a hidden file in a user's home directory and must be owned either by the user executing the command or by the root user. If the .netrc file contains a login password, the file's permissions must be set to 600 (read and write by owner only).
| Note |
|---|
|
The .netrc file is not used by any programs when the securetcpip command is running on your system. |
The ftp command interpreter provides facilities to load macros from the $HOME/.netrc file. With the .netrc file, you can simplify repetitive tasks and use the ftp command in unattended modes.
| Note |
|---|
|
The maximum size of the .netrc file is 4096 bytes. If you need to use more than 4096 bytes, you have to split up your file into multiple parts and write a script to automate the FTP job. |
The .netrc file can contain the following entries (separated by spaces, tabs, or new lines):
A sample .netrc file is created by modifying one of
the files created by the fixdist package. Only one of the
fixes to be downloaded is retained for illustration purposes. In essence,
Figure 98 shows the content of a typical .netrc file.
Figure 98: A Sample .netrc File
If you are using your own user name and password, replace anonymous with your own user name and pw0rd with your password.
You can use a simple script to handle multiple .netrc
files to use the ftp command in unattended mode. When you are
downloading a large number of fixes, do this after office hours in unattended
mode. The fixdist package will create multiple .netrc
files with suffixes 1, 2, 3, and so on such that each file is smaller than 4096
bytes. The sample script as shown in Figure 99 will copy
each .netrc file with suffixes 1, 2, 3, and so on to the $HOME directory and
then execute the ftp command.
#!/usr/bin/ksh
for i in .fixdist_home/.netrc[0-9]* # .netrc0 1 2...10 11 12...
do
cp $i .netrc # ftp script to be used
ftp -v service.software.ibm.com >> ./ptfload.log 2>&1
# Download fixes and save output
done
rm .netrc # Clean up ftp script
|
| Note |
|---|
|
Additional coding should be added to verify whether the download of individual fixes has been successful and include a housekeeping routine, if needed. But that is outside the scope of FTP and the .netrc file. |
Submit the job using the at command so that the script will be executed at the time you have planned. For example, if you have a script called getfixes and you want to schedule it to run at 11 p.m. on 2 November 1998, you will use:
at -f getfixes -t 199811022300