Off the top of my head this would be a simple bash script that would call the app. Could look like this.
This is my quick idea. I have not tested it. Could use some work.

===== START BASH SCRIPT =====
#!/bin/bash

OUR_PID=$$

# Get the basename of the program to run
APP_NAME=$0
NANE_LENGTH=${#APP_NAME}
SHORT_NAME_LENGTH=`expr $NANE_LENGTH - 4`
CALLED_APP_NAME=`echo "$0" | cut -b -$SHORT_NAME_LENGTH`

# Use a PID lock file to see if it is already running
LOCK_FILE="$HOME/tmp/${CALLED_APP_NAME}.lock
LOCK_PID=0
if [ -f $LOCK_FILE ]; then
    LOCK_PID=`< $LOCK_FILE`
fi

if [ $LOCK_PID -gt 0 ]; then
    # It was run before, we have a PID but it could be an old PID
    # See if that program is still running by this user, match the PID, the program name and the user
    STILL_RUNNING=`ps -p $LOCK_PID -u | grep ^$USER | grep $CALLED_APP_NAME`

    # Something returned means it is still running
    if [ ! "$STILL_RUNNING" = "" ]; then
        exit 0
    fi

    # Nothing returned means it is an old PID
fi

# Put our PID into the file to stop this script from running twice
# This is fast because the program we call could be slow to start up
echo -n "$OUR_PID" > $LOCK_FILE

# Call the app and give it any passed argument, get the PID and put it into the lock file
$CALLED_APP_NAME $@ &
CALLED_PID=$!
echo -n "$CALLED_PID" > $LOCK_FILE
exit 0
===== START BASH SCRIPT =====

Then use this script as a wrapper for the program. If your program is mozilla in /usr/bin/mozilla make the bash script /usr/bin/mozilla.bsh

If you have a lot of programs you want to wrap use sym links. Save the script as /usr/bin/RunOnlyOnce.bsh
ln -s /usr/bin/RunOnlyOnce.bsh /usr/bin/mozilla.bsh
ln -s /usr/bin/RunOnlyOnce.bsh /usr/bin/gedit.bsh
ln -s /usr/bin/RunOnlyOnce.bsh /usr/bin/kmail.bsh
ln -s /usr/bin/RunOnlyOnce.bsh /usr/bin/someprogram.bsh






On Wed, 2005-11-09 at 03:24 -0800, Jhommer Oblego wrote:
Hello,
Just want to ask if there is a program or script that
limits the applications to only runonce specially on
clicking on desktop icon?

I having problem on users doing multiple click on
desktop icon or program menu and results to multiple
program execution which slowdown the server and
sometimes hang the server.

do you have any suggestions on how to address this problem?


		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_____________________________________________________________________
Ltsp-discuss mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help,   try #ltsp channel on irc.freenode.net


Royce Souther
www.SiliconTao.com
Let Open Source help your business move beyond.

For security this message is digitally authenticated by GnuPG.



Reply via email to