The Dot Slash Thing
The next
step
is to try running the
script by entering its name at the Unix command prompt. You may be
able to do this by just entering the name of the script
(hello.plx
) all by itself. Or you may need to
precede its name by a period and a forward slash
(./
). What decides this is whether the dot
(.
), which you will recall is a shortcut for the
current working directory (meaning the directory you are currently
in), is in your command path
.
The command path is just a list of directories that the shell looks in to find the command whose name you entered. On a DOS system, the current working directory is in your command path by default, but not so under Unix.
If the current working directory isn’t in your command path,
entering hello.plx
by itself at the shell prompt
will not work because the Unix shell will not be able to find the
script, even though it’s right there. Instead, you’ll
have to enter ./hello.plx
, with that initial dot
slash
(./
) telling the Unix
shell to look in the current working directory for the command whose
name you’re typing in.
Tip
Having to explicitly enter the ./
before your
program’s name can actually be a good thing because it makes it
less likely that you will accidentally run a different program with
the same name in some other directory that is in your command path.
You can check to see if the current working directory is in your
command path with the
printenv
command, as follows:
[jbc@andros jbc]$ printenv PATH
/usr/local/bin:/bin:/usr/bin:/usr/sbin:. ...
Get Perl for Web Site Management now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.