You can run your new shell program in several ways. Each method will produce the same results, which is a testament to the flexibility of using the shell with Linux. One way to run your shell program is to execute the file myenv from the command line as if it were a Linux command:
A second way to execute myenv under a particular shell, such as pdksh, is as follows:
$ pdksh myenv
This invokes a new pdksh shell and passes the filename myenv as a parameter to execute the file. A third way will require you to create a directory named bin in your home directory, and to then copy the new shell program into this directory. You can then run the program without the need to specify a specific location or to use a shell. You do this like so:
This works because Ubuntu is set up by default to include the executable path $HOME/bin in your shell's environment. You can view this environment variable, named path, by piping the output of the env command through fgrep like so:
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin: \ /usr/X11R6/bin:/sbin:/home/paul/bin
As you can see, the user (paul in this example) can use the new bin directory to hold executable files. Another way to bring up an environment variable is to use the echo command along with the variable name (in this case, $path):
Never put . in your $path in order to execute files or a command in the current directorythis presents a serious security risk, especially for the root operator, and even more so if . is first in your $path search order. Trojan scripts placed by crackers in directories such as /tmp can be used for malicious purposes, and will be executed immediately if the current working directory is part of your $path.
Was this article helpful?