Hi Rowell,
I’d be looking at running a task list command – Oh flashback : I think we touched on this recently.
Wmic – my new best friend:
C:\WINDOWS\system32>wmic process where "name='w4gldev.exe'" get commandline /format:list
CommandLine="C:\Program Files\Ingres\ingresXH\ingres\bin\w4gldev.exe" "runimage" "workbnch.img" -cclassic -Tmin -Lworkbench.log ""
That way you can work out what image file is being used and make decision.
My nefarious brain says – what if they started another cause the first one crashed in a tight loop?
Cheers
Adrian
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/8ea27239-8ab6-49b2-a6ab-a28684939776n%40googlegroups.com.
Morning/Afternoon,
No Worries – my fault really, once we get to know you we can get it right.
I’m not proofing any of this as I type (think of it as pseudo-code) it is coming from memory and sometime it is not quite right but I hope this nudges you along.
I would be running that wmic command from the OpenROAD app with something like a ‘call system’ (in the past people created a 3gl Proc in OpenROAD to map the Windows API ‘Winexec’ function instead, but OpenROAD has evolved)
Call System: https://docs.actian.com/openroad/11.2/index.html#page/LangRef/Call_System_Statement.htm
Mostly you are trying to avoid a blank DOS box appearing as the app starts up.
ProcessWindow Attribute: https://docs.actian.com/openroad/11.2/index.html#page/LangRef/ProcessWindow_Attribute.htm
In that command I would re-direct to a file:
wmic process where "name='w4glrun.exe'" get commandline /format:list > w4gltasklist.txt
So I’ve changed it to be w4glrun.exe instead of w4gldev.exe and added a redirect.
So you have to think – that file I am redirecting to – will there be lots of people logging on to this machine creating contention?
Do I need to add the user name or some other identifier to make it unique?
You will have to think about where you will put it – and do you delete it afterwards (II_TEMPORARY) ?
A number of questions for you think about in the context of your environment, but a skeleton idea might be:
II_TMP = varchar(2000);
Checkw4glrun = varchar(2000) not null; // Command to run
Checkw4glrun_file = varchar(2000) not null; //Results file name
Otherw4glrun_so = StringObject; //To load the resulting file.
.
.
.
II_TMP = CurSession.Getenv(name = ‘II_TEMPORARY’ );
Checkw4glrun_file = II_TMP+’\w4gltasklist.txt’;
Checkw4glrun = ‘wmic process where "name='w4glrun.exe'" get commandline /format:list >’ + Checkw4glrun_file
//Stop the dreaded black box:
CurSession. ProcessWindow = FALSE;
Call system Checkw4glrun;
//Check the errorlevel….
If CurSession. CallSystemStatus!= 0 then….something went wrong
//Load the results
Otherw4glrun_so.Filename = Checkw4glrun_file;
//Delete the file? May have to use the Windows API
//Parse your stringobject using StringObject.Split() method.
//Look for others….
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/2c409412-0a99-48d0-a88a-ce228535d582n%40googlegroups.com.
Hi,
OK it’s Friday I knocked this up and checked it compiled.
I still reserve the right to have got bits wrong….
procedure CheckForOtherw4glrun
(
) =
declare
II_TMP = varchar(2000);
Checkw4glrun = varchar(2000) not null; // Command to run
Checkw4glrun_file = varchar(2000) not null; //Results file name
Otherw4glrun_so = StringObject; //To load the resulting file.
w4glrunprocs = array of stringobject;
isrunning = i4 not null;
i = i4 not null;
enddeclare
{
II_TMP = CurSession.Getenv(name = 'II_TEMPORARY' );
if II_TMP is null then
//it is not defined..
CurExec.Trace(text = 'Something went wrong II_TEMPORARY is null ' );
exit;
endif;
Checkw4glrun_file = ifnull(II_TMP,'')+'\w4gltasklist.txt';
Checkw4glrun = 'wmic process where "name='+HC_QUOTE+'w4glrun.exe'+HC_QUOTE +'" get commandline /format:list >' + Checkw4glrun_file;
//Stop the dreaded black box:
CurSession.ProcessWindow = FALSE;
Call system Checkw4glrun;
//Check the errorlevel….
If CurSession.CallSystemStatus != 0 then
CurExec.Trace(text = 'Something went wrong errorlevel = ' + varchar(CurSession.CallSystemStatus ));
else
//Load the results
Otherw4glrun_so.FileHandle = Checkw4glrun_file;
//Parse your stringobject using StringObject.Split() method.
w4glrunprocs = Otherw4glrun_so.Split(delimiter = HC_NEWLINE);
isrunning = 0;
for i= 1 to w4glrunprocs.lastrow do
//Look for others….
if w4glrunprocs[i].locateString(match = 'myapp.img') != 0 then
isrunning = isrunning + 1;
endif;
endfor;
if isrunning > 1 then
exit; //?
endif;
//Delete the file? May have to use the Windows API
endif;
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/001201d892a1%24e3b1a610%24ab14f230%24%40rationalcommerce.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/001201d892a1%24e3b1a610%24ab14f230%24%40rationalcommerce.com.
Friday yeah!
Rowell, you might like a simple blunderbuss approach which we use to address the problem where the OpenROAD process may be stuck, or minimised off the screen. This is especially useful for the mobile/handheld devices connected via Citrix. When the forklift operator goes out of wifi range, the connections sometimes drops but the session remains, so the forklift driver reconnects, the existing app will be terminated. Here are some commands to demonstrate:
C:\Temp>tasklist /FI "IMAGENAME eq w4gldev.exe" 2>NUL | find /I /N "w4gldev.exe" [4]w4gldev.exe 76044 13 238,752 K [5]w4gldev.exe 23856 ICA-CGP#19 4 247,472 K C:\Temp>echo %errorlevel% 0 C:\Temp>tasklist /FI "IMAGENAME eq w4gldev.exe" /FI "USERNAME eq %USERNAME%" 2>NUL | find /I /N "w4gldev.exe" C:\Temp>echo %errorlevel% 1
And an excerpt from the application start up script
tasklist /FI "IMAGENAME eq w4glrun.exe" 2>NUL | find /I /N "w4glrun.exe">NUL if not "%ERRORLEVEL%"=="0" goto kill w4glrun goto startup :kill w4glrun taskkill /f /im w4glrun.exe :startup start/min %II_SYSTEM%\ingres\bin\w4glrun.exe %IMAGEPATH% -d%DB% %TRACE%
Paul
&
Here is an example without using a temporary file.
The procedure returns an integer - TRUE if
the image (specified by the imagename parameter) run by w4glrun.exe was found, FALSE otherwise.
procedure
CheckRunningImage
(
imagename = varchar(100) not null
) =
declare
rv = INTEGER NOT NULL;
pwait = INTEGER NOT NULL;
pwin = INTEGER NOT NULL;
cmd = varchar(2000) not null;
enddeclare
{
pwait = CurSession.ProcessWait;
pwin = CurSession.ProcessWindow;
CurSession.ProcessWait = TRUE;
CurSession.ProcessWindow = FALSE;
cmd = 'cmd /c wmic process where "name=''w4glrun.exe''" get CommandLine | findstr ' + imagename;
CALL SYSTEM :cmd;
IF CurSession.CallSystemStatus = 0 THEN
rv = TRUE; // image was found
ENDIF;
// Restore original values
CurSession.ProcessWait = pwait;
CurSession.ProcessWindow = pwin;
RETURN rv;
}
Cheers,
Bodo.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/002301d892a5%2415944f90%2440bceeb0%24%40rationalcommerce.com.