Greetings
I'm developing my first ULP that needs to react differently depending on the
operating system.
What is considered the preferred method of determining the Operating System
from within a ULP?
Any advice appreciated.
Thanks
Warren
Greetings
I'm developing my first ULP that needs to react differently depending on the
operating system.
What is considered the preferred method of determining the Operating System
from within a ULP?
Any advice appreciated.
Thanks
Warren
"Warren Brayshaw" <warrenbrayshaw@paradise.net.nz> wrote in message
news:iudv2t$ucs$1@cheetah.cadsoft.de...
Greetings
I'm developing my first ULP that needs to react differently depending on
the
operating system.
What is considered the preferred method of determining the Operating
System
from within a ULP?
I'd say use the system() function to try executing "ver" for windows..
"uname " or "lsb_release -a" for linux.. And something similar for
mac?
Not a good solution tho.
Morten Leikvoll wrote on Wed, 29 June 2011 05:51
"Warren Brayshaw" <<private_email>> wrote in message
news:iudv2t$ucs$<private_email>...
Greetings
I'm developing my first ULP that needs to react differently
depending on
the
operating system.
What is considered the preferred method of determining the
Operating
System
from within a ULP?
I'd say use the system() function to try executing "ver" for windows..
"uname " or "lsb_release -a" for linux.. And something similar
for
mac?
Not a good solution tho.
I looked into something like this about a year ago for the same reason.
From memory, I believe the ver command was the way I did it. In Windows
you get back an error message and Mac and Linux give you something you can
parse. I had to pipe it to a file and then search the file. Ugly, but it
did work.
Cheers,
James.
--
James Morrison ~~~ Stratford Digital
Specializing in CadSoft EAGLE
Online Sales to North America
Electronic Design Services
EAGLE Enterprise Toolkit
--
Web access to CadSoft support forums at www.eaglecentral.ca. Where the CadSoft EAGLE community meets.
Am 29.06.2011 16:28, schrieb James Morrison:
I looked into something like this about a year ago for the same reason.
From memory, I believe the ver command was the way I did it. In Windows
you get back an error message and Mac and Linux give you something you can
parse. I had to pipe it to a file and then search the file. Ugly, but it
did work.
Everything executed via the 'system' command has the problem that it at
least flashes the DOS shell window (when run under Windows), which is a
nuisance. If you're only interested in knowing the difference between
Windows and anything else, do it as follows:
int IsWindows() {
//Returns 1, if EAGLE is running under Windows (0 for Linux/Mac)
if ((strsub(argv[0],0,1)=="/") && (strsub(argv[0],0,2)!="//"))
return 0;
return 1;
}
This does NOT call any external program and, for our institute, works
reliably since years. But, yes, I AM interested in getting to know how
to reliably tell the difference between a Mac and Linux...
Andreas Weidner
James Morrison: wrote
>> I looked into something like this about a year ago for the same
>> reason. From memory, I believe the ver command was the way I did
>> it. In Windows you get back an error message and Mac and Linux give
>> you something you can parse. I had to pipe it to a file and then
>> search the file. Ugly, but it did work.
Andreas Weidner wrote:
Everything executed via the 'system' command has the problem that it
at least flashes the DOS shell window (when run under Windows), which
is a nuisance. If you're only interested in knowing the difference
between Windows and anything else, do it as follows:
int IsWindows() {
//Returns 1, if EAGLE is running under Windows (0 for Linux/Mac)
if ((strsub(argv[0],0,1)=="/") && (strsub(argv[0],0,2)!="//"))
return 0;
return 1;
}
This does NOT call any external program and, for our institute, works
reliably since years. But, yes, I AM interested in getting to know how
to reliably tell the difference between a Mac and Linux...
Andreas Weidner
Thanks for the replies everyone. If there are further methods being used by
others I would like to here about them.
My current needs, as I understand them at this point, is to be able to
determine Windows from the other two. Andreas' solution is elegant.
Other ideas:
For those installations where there are two paths in the Eagle
Options/Directories you could detect the semicolon (Windows) or colon
(Linux-Mac) in eaglerc.usr
Detecting eaglerc.usr or .eaglerc may be possible also but gives no more
than Andreas' solution.
That said it would be good to determine a technique that does differentiate
between Linux and Mac.
Something like detecting a root folder lib (Linux) or Library (Mac)? Or var
(Linix) vs System (Mac)?
In a well locked down institution, can a user still detect the presence of
these folders?
I have been trying a few ideas via JavaScript or vbs to get past the
flashing command window and this could be another path to obtaining the OS
but comes with security issues.
Would be OK for institutions with a certificate server.
Right now I'm having an issue with the system() command (I think) adding
eagles install path ahead of my path. Yet to solve that one, if its possible
Regards
Warren
James Morrison: wrote
>> I looked into something like this about a year ago for the same
>> reason. From memory, I believe the ver command was the way I did
>> it. In Windows you get back an error message and Mac and Linux give
>> you something you can parse. I had to pipe it to a file and then
>> search the file. Ugly, but it did work.
Andreas Weidner wrote:
Everything executed via the 'system' command has the problem that it
at least flashes the DOS shell window (when run under Windows), which
is a nuisance. If you're only interested in knowing the difference
between Windows and anything else, do it as follows:
int IsWindows() {
//Returns 1, if EAGLE is running under Windows (0 for Linux/Mac)
if ((strsub(argv[0],0,1)=="/") && (strsub(argv[0],0,2)!="//"))
return 0;
return 1;
}
This does NOT call any external program and, for our institute, works
reliably since years. But, yes, I AM interested in getting to know how
to reliably tell the difference between a Mac and Linux...
Andreas Weidner
Thanks for the replies everyone. If there are further methods being used by
others I would like to here about them.
My current needs, as I understand them at this point, is to be able to
determine Windows from the other two. Andreas' solution is elegant.
Other ideas:
For those installations where there are two paths in the Eagle
Options/Directories you could detect the semicolon (Windows) or colon
(Linux-Mac) in eaglerc.usr
Detecting eaglerc.usr or .eaglerc may be possible also but gives no more
than Andreas' solution.
That said it would be good to determine a technique that does differentiate
between Linux and Mac.
Something like detecting a root folder lib (Linux) or Library (Mac)? Or var
(Linix) vs System (Mac)?
In a well locked down institution, can a user still detect the presence of
these folders?
I have been trying a few ideas via JavaScript or vbs to get past the
flashing command window and this could be another path to obtaining the OS
but comes with security issues.
Would be OK for institutions with a certificate server.
Right now I'm having an issue with the system() command (I think) adding
eagles install path ahead of my path. Yet to solve that one, if its possible
Regards
Warren