On 22:49 07 Sep 2002, Mikhael Goikhman <migo_at_homemail.com> wrote:
| On 07 Sep 2002 23:28:29 +0200, Johan Svedberg wrote:
| > I need some help. What I want to do is check if a program is on my
| > system, and if it is I want to run it in my InitFunction. I'm guessing
| > this could be done in a Function using PipeRead, but I have no idea how
| > to do it... :-) Help would be greatly appriciated.
|
| Do what you would do from a script or command line. Something like this:
|
| Exec which myprogram >/dev/null 2>&1 && myprogram params
|
| Some propretary unices (Solaris) have pretty unusable "which" that always
| returns 0 and write errors on stdout. There are also "whereis" (external),
| "where", "filetest -X" (tcsh/csh), "hash", "type" (sh).
Any reason not just to do this:
Exec myprogram params
If it's there, it runs. If not, it doesn't.
Of course, if you want to do a bit more than just invoke it
then Mikhael's approach is the go. If your "which" always returns 0 you
can try this:
Exec prog=`which myprogram 2>/dev/null`; [ -f "$$prog" ] && myprogram params
i.e. doesn't trust which's exit status - test the string it returns. The
double $$ is to get the $ through to the shell from FVWM (which also
uses $).
--
Cameron Simpson, DoD#743 cs_at_zip.com.au http://www.zip.com.au/~cs/
As long as you're willing to distract people with odd host names, the British
Indian Ocean Territory appears to be a safe bet; unlike .cv, .cm, and .vg,
there is still no name service for .io, making it ripe for fictional hosts.
According to my almanac, it contains the Chagos Archipelago, with a surface
area of 23 square miles and no civilian population whatsoever, although both
the UK and the US "maintain a military presence". Presumably any computers it
contains will be in .mil or .uk. - Elizabeth Zwicky <zwicky_at_greatcircle.com>
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Sat Sep 07 2002 - 20:44:50 BST