Hi! I have looking for code to do that also... but your code doesn't work with me. It always finds two instances of my program; 1. the program it self 2. sh -c pgrep -f -l ProgramName (option -l is just for debugging, it doesn't matter)
This happens with Gambas 2.10 at Ubuntu 8.10 64bit. This did NOT fix the problem: SHELL "pgrep -f -l " & Application.Args[0] WAIT TO sShellOutput But this works: Exec ["pgrep", "-f", "-l", Application.Args[0]] To sShellOutput And just for case: Exec ["pgrep", "-f", "-l", Application.Args[0]] Wait To sShellOutput So, just to warn, and thanks for idea! Jussi On Wed, Apr 22, 2009 at 14:47, Siti Fatimah <sfatima...@yahoo.com> wrote: > Thank's Stefano ..for ur quick response. It really worked.... > > Best Regards, > sfatimah > > --- Pada Rab, 22/4/09, Stefano Palmeri <rospolo...@tiscali.it> menulis: > > > Dari: Stefano Palmeri <rospolo...@tiscali.it> > Topik: Re: [Gambas-user] How prevent application from opening twice > Kepada: "mailing list for gambas users" <gambas-user@lists.sourceforge.net> > Tanggal: Rabu, 22 April, 2009, 4:19 AM > > > Il mercoledì 22 aprile 2009 13:11:59 Siti Fatimah ha scritto: >> Hi all, >> I need to prevent my program from opening twice. Is there a best method to >> determine whether a program has already run ? >> >> Thanks. >> sfatimah >> > > I use this: > > DIM sShellOutput as String > SHELL "pgrep -f -U " & User.Name & " " & Application.Args[0] TO sShellOutput > > IF Split(Trim$(sShellOutput), "\n").Count > 1 THEN > > 'already running > 'take action here > > ENDIF > > This check for the user. If you want to check system > wide, do: > > SHELL "pgrep -f " & Application.Args[0] TO sShellOutput > > Bye, > > Stefano > > >> >> >> Berselancar lebih cepat. Internet Explorer 8 yang dioptimalkan untuk >> Yahoo! otomatis membuka 2 halaman favorit Anda setiap kali Anda membuka >> browser. Dapatkan IE8 di sini! >> http://downloads.yahoo.com/id/internetexplorer >> --------------------------------------------------------------------------- >>--- Stay on top of everything new and different, both inside and >> around Java (TM) technology - register by April 22, and save >> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. >> 300 plus technical and hands-on sessions. Register today. >> Use priority code J9JMT32. http://p.sf.net/sfu/p >> _______________________________________________ >> Gambas-user mailing list >> Gambas-user@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > Berselancar lebih cepat. Internet Explorer 8 yang dioptimalkan untuk > Yahoo! otomatis membuka 2 halaman favorit Anda setiap kali Anda membuka > browser. Dapatkan IE8 di sini! > http://downloads.yahoo.com/id/internetexplorer > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user