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
  • 5
  • 4
    Possible duplicate of [How can I run this sh script without typing the full path?](http://askubuntu.com/questions/427818/how-can-i-run-this-sh-script-without-typing-the-full-path) – muru Feb 04 '16 at 04:45
  • `./` is the file's path. Writing NOT in all caps doesn't change that. – muru Feb 04 '16 at 04:58
  • Oh, sorry. I didn't know that. I'll edit it out. – Ranger Feb 04 '16 at 04:59

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
  • 4
  • 13