Loïc Grenié on Tue, 24 Sep 2024 15:37:07 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: my attempt to find operating system


On Wed, 24 Sep, 2024 at 13:34, Jean-Luc Arnaud wrote:
Thanks for your help, American Citizen.

Below is a script working either on Mac OS, Windows or Linux, whatever is the name and the content of the log.
I'm quiet sure it could be simplified, maybe using 'select' function.

f=default(logfile);
\v
k=readstr(f);

for(i=1, +oo, iferr(b=strsplit(k[i]," "); if(setsearch(b,"darwin")>0, print("MacOS"); return, if(setsearch(b,"mingw")>0,  print("Windows");return, if(setsearch(b,"linux")>0, print("Linux"); return))), E, print("OS non déterminé"); return));

default(log,0);
Bill, could you create a new function called, let say, 'OSType' and returning "MacOS", "Linux" or "Windows" as string?

In addition, is there a corresponding function for \v, as there is defaut(log,x) for \l?
With \v, there is an annoying display of the returned information, like with \l, but no display with "default(log,x);".😉

     Maybe externstr("echo quit | gp -f") could do the trick (I don't know if echo works
  under windows, but it should because I think it is emulated).

            Loïc

 


Le 22/09/2024 à 00:36, American Citizen a écrit :
This script seems to work for me

? \l
   log = 1 (on)
   [logfile is "pari.log"]
? \v
                  GP/PARI CALCULATOR Version 2.16.2 (development git-cd66bbd045)
                   amd64 running linux (x86-64/GMP-6.3.0 kernel) 64-bit version
compiled: Apr 25 2024, gcc version 13.2.1 20240206 [revision 67ac78caf31f7cb3202177e6428a46d829b70f23] (SUSE Linux)
                                     threading engine: single
                          (readline v7.0 enabled, extended help enabled)
? k=readstr("pari.log");
? k[4]
%2 = "                   amd64 running linux (x86-64/GMP-6.3.0 kernel) 64-bit version"

You could parse this line for the operating system.

and then turn off logging again

? \l
   log = 0 (off)
   [logfile was "pari.log"]