Question Paul Dayan · Nov 9, 2018

How to get running operating system

Can anyone tell me how to discover in ObjectScript the operating system and operating system version that Caché is actually running in? (Not the operating system the build was compiled for.)

Comments

Paul Dayan  Nov 9, 2018 to Robert Cemper

Thanks, Robert - really great to hear from you. I hope you are well.

And very interesting to learn about $systeminfo - it certainly provides a wealth of information about the environment. Unfortunately $systeminfo takes a few seconds to run, which is too slow when it might be required for many messages. I'll keep looking! If all else failsI guess I could get the information from $systeminfo when my business operation starts, and hold it in the business operation properties. So if you do happen to come across the equivalent for Linux and other platforms, please let me know.

0
Eduard Lebedyuk  Nov 10, 2018 to Robert Cemper

Windows also has Ver command:

USER>$Ver

Microsoft Windows [Version 10.0.17134.345]
0
Robert Cemper  Nov 10, 2018 to Robert Cemper

from Caché prompt:

USER>$uname -a
Linux MYSERVER 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

 
0
Robert Cemper · Nov 10, 2018

something fast for WINDOWS

USER>$wmic os list brief
 
BuildNumber  Organization  RegisteredUser  SerialNumber             SystemDirectory      Version
17134                      cemper          0                      0 C:\WINDOWS\system32  10.0.17134
0
Eduard Lebedyuk  Nov 10, 2018 to Robert Cemper

Is there an easier way to get value from OS call then Input redirection?

0
Ben Spead  Nov 10, 2018 to Eduard Lebedyuk

check out the ##class(%Studio.SourceControl.ISC).RunCmd() method for an easy way to capture the OS output

0
Eduard Lebedyuk  Nov 10, 2018 to Ben Spead

Thanks!

I see it still uses $zf(-1) in latest instead of $zf(-100). I thought $zf(-1) is unavailable now.

0
Ben Spead  Nov 12, 2018 to Eduard Lebedyuk

It's deprecated but still available.  Swapping it out for $zf(-100) for %Studio.SourceControl.ISC is on the TODO list...

0
Robert Cemper · Nov 10, 2018

and for Linux:

(don't have a Caché  installation at hands)  but  CPIPE should do it

rcemper@ubuntu:~$uname -a
Linux anyServer
4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
rcemper@ubuntu:~$ 

 
0
Ben Spead · Nov 10, 2018

You can use $version(1) to see if it is Windows (returns '2') or UNIX (returns '3').  If you want to get really fancy you can include %occOptions.inc and then use the $$$isUNIX and $$$isWINDOWS calls (which just check to see if $version(1) is 2 or 3).

Personally, I like using ##class(%Studio.SourceControl.ISC).RunCmd() as it wraps the capture of the output for parsing.

You can tie $version together the other answers into something that is platform independent (warning, I haven't tested this, but I believe the pieces work):

If ($version(1)=2) {

   //Is Windows

   set sc=##class(%Studio.SourceControl.ISC).RunCmd("Ver",.out,0)

   set OS = out(1)

   // exercise of parsing exact desired version piece from the string is an exercise left to the reader

} elseif ($version(1)=3) {

   //Is UNIX

   set sc=##class(%Studio.SourceControl.ISC).RunCmd("uname -a",.out,0)

   set OS = out(1)

   // exercise of parsing exact desired version piece from the string is an exercise left to the reader

}

Hope that helps you Paul!

0