0

Using a shebang line, I added the functionality to launch a TCL script using the wish shell. However, I can only quickly launch the file by typing ./filename.tcl in the terminal. I would like to know, is there a way to run the same script without typing the ./ before the filename?

Ranger
  • 3

1 Answers1

3

If you leave out the path to the file then your shell is going to look for the command via the $PATH variable. The "." is the current directory, which provides a path to the file. Your options are:

Put the file inside a subdirectory like bin:

$ bin/filename.tcl

This is most likely not what you want. What you might want is to alter your $PATH to include the current directory.

$ PATH=$PATH:. filename.tcl

It's most likely not wise to export the current directory to the $PATH variable as it may cause some unexpected behavior. It may be better to export the full path to your bin directory. So for example if you were working at $HOME/my/code/bin/filename.tcl then you could add this to your .bashrc (or whatever shell config file you use)

export PATH="$PATH:$HOME/my/code/bin"

Then you should be able to run

filename.tcl

Without specifying the path to the directory.

iridian
  • 389