which

A bash one-liner to change into the directory where some file is located.

I often want to change to the directory where a particular executable is located. So I'd like something like cd `which python` to change into the directory where the python command is installed. However, this is obviously illegal, since cd takes a directory, not a file. There is obviously some regexp-foo I could do to strip off the...

Is there a Perl module that works similarly to the Unix "which" command?

I was on Perlmonks and found this great listing: http://www.perlmonks.org/?node_id=627015 But it was missing "which", the function that searches for an executable in all the directories in your PATH. (I am porting a Perl script to Windows.) Is there a Perl module that simulates this? ...

Python analog of Unix 'which'

In *nix systems one can use which to find out the full path to a command. For example: $ which python /usr/bin/python or whereis to show all possible locations for a given command $ whereis python python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-config /lib/python2.4 /lib/python2.5 /usr/lib/python...

Wordpress or Code Ignitor?

As a quick background. I am a web developer. I tried to develop 10-15 of my domains. Due to lack of time/focus, none got anywhere - as such I decided to focus on two, and do them properly. In the past, I have used wordpress for a CMS of sorts. One of the sites is essentially a blog with additional PHP based dynamic features. Using the P...

BASH script - How to get bash to check for the location of a file?

Hi I want my bash script to find where php is installed - this will be used on different linux servers, and some of them won't be able to use the which command. Anyway I need help with that second line: #!/bin/bash if (php is located in /usr/bin/php); then PHP = /usr/bin/php else PHP = /usr/local/zend/bin/php fi $PHP script.php ...

Running shell_exec('which java') in PHP return nothing

If I run which java from the command line I get the proper input (/usr/java/.../bin/java). However if I run it in a php script: <? echo 'java. ' . shell_exec('which java'); echo 'ls. ' . shell_exec('which ls'); ?> nothing gets printed out for which java but I get the proper results for which ls... ...

Is there a Perl equivalent of which?

Possible Duplicate: Is there a Perl module that works similarly to the Unix which command? I'm looking for an equivalent of which in Perl that would give me the full path to a program according to the current $ENV{PATH}. Is there a CPAN module to do that? Or should I roll my own? ...