erratic has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys,
can anyone help me with this ? I've got a perl script in one directory, and I want to be able to access it while working in other directories. Now, I don't have the permissions necessary to put it in the usr/bin directory. I've created a .tcshrc file in my home directory, with
set path = ($path /home/Programs) (where the program is located), but it doesn't have any effect. When I try "./Program.pl" (name of program) while in another directory, I get "bash: ./Program.pl: No such file or directory".

any advice would be greatly appreciated.

Replies are listed 'Best First'.
Re: setting path to perl script in UNIX
by b10m (Vicar) on Jan 23, 2004 at 13:18 UTC

    This is quite off-topic, since it has nothing really to do with Perl, yet, I'll try to help you out.

    Launching a ./Program.pl means, "Please, shell, launch the script Program.pl which is located in ./" The dot-slash means the current directory you're in. You could use /home/Programs/Program.pl in any directory, but that's quite annoying to type every time.

    If you set the path in your ~/.tcshrc, as specified, you should be able to call Program.pl without a problem (drop the dot-slash in front of it).

    Another thing that strikes me as odd, is the fact that you speak of a ~/.tcshrc (tcshell), yet the error is coming from bash (another shell). So you probably want to add the following line in your ~/.bash_profile:

    PATH=$PATH:/home/Programs export PATH

    This way, you alter the path for bash (which you seem to use anyway). Save these additions to ~/.bash_profile (or ~/.profile) and the next time you login, you can launch your script by typing "Profile.pl" :)

    --
    b10m
Re: setting path to perl script in UNIX
by Abigail-II (Bishop) on Jan 23, 2004 at 13:15 UTC
    This has nothing at all to do with Perl, and everything with Unix (and shells), so I keep it brief.

    ./Program.pl contains a slash. That means, the setting of your path is irrelevant. You ask for the program Program.pl in the current directory to be executed. Which isn't there to begin with. Either use just the name of the program you want to execute, a relative path to the executable, or an absolute path.

    Abigail

Re: setting path to perl script in UNIX
by derby (Abbot) on Jan 23, 2004 at 13:26 UTC
    It's been a long time since I used tcsh (I tend to prefer bash these days). IIRC, just changing the value in the .tcshrc file is not going to immediately export the new path value to the environment. You either need to start a new shell (by log'ing out then back in or invoking a sub tsh process), or you need to source the .tshrc file.

    Also, the *nix way is to create a bin directory in your home directory - /home/user/bin. But maybe your running Mac OS X in which case, /home/user/Applications seems to be the appropriate vendor approach!

    -derby