Writing ftp macros
These steps describe how to create an ftp macro.
You must have created the $HOME/.netrc file.
To write an ftp macro:
- Edit the $HOME/.netrc file to include the
following instructions:
macdef init put schedule
Be sure to insert a blank line at the end of your ftp macro. The blank line terminates the ftp macro. In the above example, the macdef subcommand defines the subcommand macro
init
. The line following is the command the macro specifies, in this caseput schedule
, where schedule is the name of a file. - After you create the ftp macro, at the command
line prompt, type:
ftp hostname
Where hostname is the name of the host to which you are connecting.
ftp scans the $HOME/.netrc file for a login definition matching your host name and uses that login definition to log you in. - After you log in, at the command line prompt, type:
ftp init
In this example, ftp scans for the macro named
init
and executes the command or commands the macro specifies.An ftp macro is associated with the login entry immediately preceding it. ftp macros are not global to the $HOME/.netrc file. The macroinit
is executed automatically upon login. Other macros can be executed from the ftp prompt (ftp>
) by typing the following:$getit
In this example, the
$
executes the ftp macro getit.