afpcmd

Command-line AFP client for browsing and transferring files over the network

SYNOPSIS

afpcmd [-V] [-f version] [-v loglevel] [-M mode] -b
afpcmd [-V] [-f version] [-v loglevel] [-M mode] afp_url
afpcmd [-r] [-V] [-f version] [-v loglevel] [-M mode] afp_url local_path
afpcmd [-r] [-V] [-f version] [-v loglevel] [-M mode] local_path afp_url
afpcmd -h

DESCRIPTION

afpcmd is a command-line tool to help transfer files to and from a server using AFP (Apple Filing Protocol). This server is typically either Netatalk running on a UNIX-like host, or AppleShare Server or personal file sharing on Classic Mac OS or Mac OS X.

This can be done as a non-root user. It offers either an interactive command-line (like a traditional FTP client) or for batch retrievals.

Do not confuse this with the FUSE mounting commands (mount_afpfs, etc.), which offers the ability to mount an entire filesystem.

Note that afpcmd depends on the afpsld(1) AFP Stateless Client Daemon running in the background to manage the AFP connection and commands. If not already running, afpcmd will attempt to start it.

OPTIONS

-b, –browse

Browses AFP services advertised on the local network using DNS-SD or Avahi. The live picker lists service names and accepts a service number or q to quit. It does not prompt for a host or address.

-h, –help

Shows the help message.

-r, –recursive

Recursively transfers directories in batch mode. This invocation-level option is not accepted in interactive mode; use -r after an interactive command name instead.

-f version, –afpversion version

Limits the AFP protocol version used to connect to the server. The version may be written with or without a decimal point, for example 3.1 or 31.

-V, –verbose

Enables verbose mode for file transfers. When enabled, displays detailed messages during upload and download operations, including per-file transfer statistics. By default, only a summary message is shown after each transfer completes.

-v, –loglevel level

Sets the log verbosity level. Accepted values are debug, info, notice, warning, and error. Default is notice. Logs are written to standard error and syslog.

-M, –metadata mode

Preserves FinderInfo, ResourceFork, generic extended attributes, modes, and modification times during transfers. This option selects the local on-disk representation used by afpcmd when metadata is copied between the AFP server and an ordinary local path; it does not configure how the AFP server stores metadata. The storage mode may be auto, netatalk, xattr, macos, or none. auto is the default; it uses local filesystem extended attributes for generic xattrs when available, and falls back to Netatalk AppleDouble EA sidecars otherwise. FinderInfo and ResourceFork use native filesystem xattrs on macOS, and macOS-compatible ._name AppleDouble files on other systems. netatalk uses .AppleDouble/name and name::EA files. xattr uses local filesystem extended attributes for generic xattrs. FinderInfo and ResourceFork use native filesystem xattrs on macOS, and macOS-compatible ._name AppleDouble files on other systems. macos uses macOS-compatible ._name AppleDouble files for FinderInfo and ResourceFork. none transfers only the data fork.

afp_url

Uses the standard AFP URL format.

BATCH MODE

Batch file transfers allow uploading or downloading files or directories without entering the interactive shell.

To download from a server:

**afpcmd** [**-rV** *afp_url* *local_path*]

To upload to a server:

**afpcmd** [**-rV** *local_path* *afp_url*]

If the -r flag is provided, the transfer is recursive (for directories). If the -V flag is provided, detailed transfer information is displayed for each file. Metadata preservation is enabled by default in both batch and interactive transfers. Symbolic links are rejected.

INTERACTIVE MODE

If a URL is provided on the command line, afpcmd connects and enters the volume and directory specified.

If -b is used, afpcmd shows a live list of advertised AFP services. Selecting a service resolves its target, advertised port, and interface-scoped address before entering the same interactive client. afpcmd then prompts for a username; leaving it blank requests guest access, while a non-empty username is followed by a hidden password prompt. To connect to a host that is not advertised, pass its AFP URL directly on the command line.

Standard readline keystrokes are enabled. Command line completion (using tab) and history (using up and down arrows) is provided. Local filename completion is enabled.

Most common commands

ls

Show files in the current directory. If no volume is attached, show a numbered volume picker; selecting a number attaches that volume, while q quits afpcmd.

cd

Change directories on the server

get [-r] filename

Retrieve a file. With -r, recursively retrieve a directory.

put [-r] filename

Upload a file. With -r, recursively upload a directory.

exit

Detach from current volume

quit

Quit the program but keep AFP connection alive

disconnect

Quit the program and shut down AFP connection; WARNING: this may disrupt other AFP clients on the same host

Remote directory commands

pwd

Show current directory on server

mkdir directory

Create new directory

rmdir directory

Remove directory

Remote file commands

mv old_file new_file

Rename old_file to new_file.

cp [-r] source destination

Copy a file from source to destination. With -r, recursively copy a directory.

touch filename

Create a blank file or update time stamp on existing file

cat filename

Show the contents of file

chmod [-r] mode file

Change the mode of a file on the server. With -r, recursively change the mode of a directory tree.

rm [-r] file

Remove a file from the server. With -r, recursively remove a directory tree.

Metadata commands

In command input, double quotes group an operand containing whitespace. Single quotes are literal characters.

xattr list path

List generic extended attributes.

xattr get path name [output]

Read an extended attribute, writing binary data to output when supplied or showing bounded hexadecimal output otherwise.

xattr set path name input

Set an extended attribute from a local binary file.

xattr remove path name

Remove an extended attribute.

finderinfo get path [output]

Read the 32-byte FinderInfo value.

finderinfo set path input

Set FinderInfo from an exactly 32-byte local file.

finderinfo remove path

Clear FinderInfo.

resourcefork get path [output]

Read a ResourceFork.

resourcefork set path input

Set a ResourceFork from a local binary file.

resourcefork remove path

Remove a ResourceFork.

comment get path

Print the AFP Desktop database comment for a file or directory. Relative paths are resolved from the current remote directory.

comment set path text

Set the AFP Desktop database comment. Whitespace in a double-quoted text is preserved. AFP 2.x comments are limited to 199 bytes; when that limit causes truncation, afpcmd reports both the supplied and stored byte counts after the update succeeds.

icon list creator

List Desktop database icons for the four-character Finder creator code.

icon get creator type icon-type local-file

Retrieve one raw AFP icon bitmap into a new local file. The destination is created exclusively and is never overwritten.

appl list creator

List Desktop APPL mappings for a Finder creator code.

appl get creator index

Show one one-based Desktop APPL mapping. For Desktop commands, a Finder creator or type is either a four-character code, such as “APPL” or “TEXT”, or eight hexadecimal digits (optionally prefixed with 0x). Output includes both an escaped code rendering and its hexadecimal value.

Status commands

status

Show status of the connection and server

df

Show the disk size and available space

Local commands

lpwd

Show current local directory

lcd directory

Change local directory

User management commands

passwd

Change the password of the current user (if the UAM supports it)

Other commands

help

Show a help message listing all commands.

AFP URLS

A typical usage of afpcmd is:

afp://username:password@servername/volume

The complete syntax of a URL is:

afp://username;AUTH=uamname:password@server:port/volume/path

If the password is omitted, or if ‘-’ (a minus) is provided as the password, the user is prompted for the password. If the username is omitted, you will attempt to authenticate as guest.

SEE ALSO

afpgetstatus(1)