Re: [SLUG] Why won't an app run from icon?

From: Ian C. Blenke (icblenke@blenke.com)
Date: Wed Nov 27 2002 - 09:24:48 EST


On Thu, Oct 11, 2001 at 06:34:28PM -0400, Bryan-TheBS-Smith wrote:
> Russ Wright wrote:
> > If I open a shell window and cd to the application directory
> > ie: "cd /usr/lib/ICAClient" and type "./wfcmgr" the app starts.
> > I decided to create a KDE desktop Icon to do the same. I linked
> > it to the same file but it does not start. Any thoughts?
>
> Yeah, what stupid UNIX program needs to be in a certain directory to
> start? That's a Windows'ism that is frowned upon. The only time
> I've seen that happen is for programs ported with WINE (is the
> ICAClient?).

Actually, this is altogether too common. Typically there is a shell
script that sets the environment appropriately for an executable to run.
Many packages, like Mozilla, do this quite commonly.

There are two common solutions to this problem.
1) Make your user environment set your PATH/LD_LIBRARY_PATH/etc appropriately
2) Make a shell script for each package that does the same

I'm a bit proponent of 2, but I keep a hand-written tuned "user-env" package
that I take with me everywhere that auto-probes the system on login and sets
my path/environment appropriately.

> So I'm sure that is your problem, unless you're setting a change
> directory in your icon. I don't use KDE, but Gnome has a field on a
> second tab in the properties called "Try this before running:" where
> I can put a "cd path". Another way to tame this would to create a
> simple shell script in /usr/local/bin (or wherever) that has two
> lines, the cd and the binary.

As most commands are exec'ed through a shell anyway, you can also
SOMETIMES use the environment-variable-set-before-running-a-command trick:

        "PATH=/usr/lib/ICAClient:$PATH wfcmgr"

There's also the "env" trick"

        "env PATH=/usr/lib/ICAClient:$PATH wfcmgr"

Typically, however, you'll only see the "env" trick as a trick to hide
the full patch of the magic line at the beginning of a shell script, ie:

        #!/usr/bin/env perl

This means that you can run your perl script with perl anywhere on your
system, as long as its in your path and there is a /usr/bin/env runtime
on your box.

But I believe the ICAClient package requires a change directory into
that path. Again, if the commands are run through a shell, you can use
the semicolon trick:

        "cd /usr/lib/ICAClient; ./wfcmgr"

or, you can set ICAROOT appropriately:

        "ICAROOT=/usr/lib/ICAClient /usr/lib/ICAClient/wfcmgr"
or
        "ICAROOT=/usr/lib/ICAClient PATH=$ICAROOT:$PATH wfcmgr"
or
        "env ICAROOT=/usr/lib/ICAClient wfcmgr"

The best bet is still to make a little shell script wrapper:

        $ cat - > /usr/local/bin/wfcmgr.sh <<EOF
        #!/bin/sh
        ICAROOT=/usr/lib/ICAClient
        exec $ICAROOT/wfcmgr $*
        EOF
        $ chmod ugo+rx /usr/local/bin/wfcmgr.sh
        $ wfcmgr.sh

Fun, isn't it? :)

- Ian



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:12:19 EDT