Re: 4GL RUN command question
Posted in 1998
Candy McCall wrote: > > >Candy McCall wrote: > > > >> I've also thought of setting a value in a shell > >> environment variable in the shell script and > >> then reading the value using fgl_getenv(), but since > >> the shell_script is a child process, I didn't think I could > >> set a shell environment variable of the parent process > >> (the 4GL program). > >> > >> A third way I've thought of is to place the integer variable > >> in an ASCII file, then using the LOAD command, load > >> the value into a temporary table. This is not the most > >> elegant way of getting that value, but it will work. > >> Does anyway know of a better way? > > > I'm trying to write a simple routine to check for the number > of concurrent users running the application using the ps command. As people have said, you can return up to 255 different values. However, that is not the same as a value of 255. The values would be: UNIX return returned as 0 to 127 0 to 127 128 NULL 129 to 255 -127 to -1 Also beware that other numbers will not give errors, but be returned as numbers in the valid range. E.g. 256 will be returned as 0, 257 as 1, etc. So as long as you don't have more than 127 users, or 255 users if you want to code for negative numbers, try something like: RUN "exit `ps -ef|grep myapp|grep -v 'grep myapp'|wc -l`" RETURNING my_smallint LET my_smallint = my_smallint/256 DISPLAY "There are ", my_smallint USING "<<<<<<", " users" Notice the back-quotes in the RUN command. Hope that helps, -- Mark. +----------------------------------------------------------+-----------+ |Mark D. Stock - Informix SA http://www.informix.com |//////// /| |mailto:mdstock@informix.com http://www.informix.com/idn |///// / //| |http://www.iiug.org +-----------------------------------+//// / ///| | Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////| | Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////| |Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////| +----------------------+-----------------------------------+-----------+