in reply to How to find whether an external commands exists

Why i don't want to execute and check ? Because, i wish to check commands such as rm, tar. If i want to check the rm by executing then, i should create a temporary file and for that i should whether i have permission or not and the process goes recursive.

As suggested above, the best thing to check where the binary lives is to use one of the modules mentioned.

However, there might be situations, where the command does not exist on PATH, like shell aliasing or internal command.

I would just run the desired command with system and check for the result with $?, as described in system documentation's example.

Replies are listed 'Best First'.
Re^2: How to find whether an external commands exists
by rovf (Priest) on May 04, 2009 at 13:11 UTC
    there might be situations, where the command does not exist on PATH, like shell aliasing or internal command.
    This is tricky. It is pretty system dependent on what the default shell for system is. If you know it is bash, you could shell out and do a type COMMANDNAME.

    -- 
    Ronald Fischer <ynnor@mm.st>