|
Programming
on your Virtual Server is different than the programming
you may have done in the past. The Virtual Server runs
in a special environment that protects and isolates one
Virtual Server from another. Because this difference is
integrated into the technology of the Virtual Server system,
it is sometimes not readily apparent. What causes additional
confusion is that Telnet (the program you use to connect
to the command line of your Virtual Server) does not run
under the Virtual Server environment. Programs are often
written and tested from a Telnet "environment,"
which is different than the environment the script runs
under when called, for example, through a web server.
Only one user has access
to Telnet (the Virtual Server administrator). When you
are logged onto your Virtual Server via Telnet, you
are not constrained by the Virtual Server environment.
You have access to many utilities that otherwise you
would not. The Telnet administrator's "environment"
includes access to much of the physical server on which
the Virtual Server resides.
When a Virtual Server
administrator connects to a Virtual Server via Telnet,
he or she arrives at a command prompt display that defaults
to their "home" directory:
virtual-server: {1}
%
Note: The above
line is a sample of how a command prompt normally appears
in a Telnet session. The rest of the chapter uses a
"%" sign to represent the command prompt.
When you run the command
pwd (print working directory), it tells you the
directory you are in:
% pwd
/usr/home/login_name
Where login_name
is the login name of the Virtual Server administrator.
The following is an example from berrett.org.
berrett: {2} % pwd
/usr/home/berrett
For services other than
Telnet, however, home directory is mapped to "/",
or "root." For example, when connecting to
a Virtual Server via FTP (using a hypothetical domain
name of "yourcompany.com") and type pwd,
it returns "/".
% ftp yourcompany.com
Connected to yourcompany.com
220 yourcompany.com ftp server (Version 5.3.2) ready.
Name (yourcompany.com:root): login_name
331 Password required for login_name.
Password:
230 User login_name logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is current directory.
ftp>
The difference between
the path seen in Telnet and other services causes a
common problem when programming CGI's. For example,
at times, administrators desire to send mail from a
script. In traditional UNIX, a call can be made to the
sendmail program to send mail. When writing scripts,
you must "path" to the program you want to
run. With UNIX, you can type which sendmail to
find the path to the program you are calling. For example:
% which sendmail
/usr/sbin/sendmail
Using which in
the above example returns path to the physical server
Sendmail, rather than your personal Virtual Server
Sendmail that resides on the physical server.
Using which for locating a programs path can
be misleading, since the path used in CGI scripts need
to be valid when run in the virtual environment. This
problem is addressed in the following sections.
|