Specifications
Chapter 1 Executing Commands 25
Executing Commands and Running Tools
To execute a command in the shell, enter the complete pathname of the tool’s
executable file, followed by arguments, and then press Return.
If a command is located in one of the shell’s known folders, you can omit path
information and enter the command name.
The list of known folders is stored in the shell’s PATH environment variable and includes
the folders containing most command-line tools.
For example, to run the ls command in the current user’s home folder, you could enter
the following at the command line and press Return:
host:~ anne$ ls
To run a command in the current user’s home folder, you would precede it with the
folder specifier. For example, to run MyCommandLineProg, you would use something
like the following:
host:~ anne$ ./MyCommandLineProg
To launch a tool package, you can use the open command (open MyProg.app) or
launch the tool by entering the pathname of the executable file inside the package,
usually something like ./MyProg.app/Contents/MacOS/MyProg.
When entering commands, if you get the message command not found, check your
spelling. Here is an example:
server:/ anne$ sudo serversetup -getHostname
serversetup: Command not found.
If the error recurs, the command you’re trying to run might not be in your default
search path. You can add the path before the command name, for example:
server:/ anne$ sudo /System/Library/ServerSetup/serversetup -getHostname
server.example.com
or change your working folder to the folder that contains the tool. For example:
server:/ anne$ cd /System/Library/ServerSetup
server:/System/Library/ServerSetup anne$ sudo ./serversetup -getHostname
server.example.com
or
server:/System/Library/ServerSetup anne$ cd /
server:/ anne$ PATH="$PATH:/System/Library/ServerSetup"
server:/ anne$ sudo serversetup -getHostname
server.example.com