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
"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?
May I ask why you need to detect this? Depending on what you try to do,
there could be alternative solutions..
Morten Leikvoll wrote:
May I ask why you need to detect this? Depending on what you try to
do, there could be alternative solutions..
The need is to provide the correct formatting for the strings passed with
the system() ULP command and the formatting of batch files created by the
ULP and used by the OS script processors.
When the system() command is involved it appears to be most common (easier)
for a ULP to be crafted solely for use with Windows or Linux/Mac. I wish to
make a ULP that will work in both environments hence the formatting needs to
be appropriate for the OS in use.
Warren
"Warren Brayshaw" <warrenbrayshaw@paradise.net.nz> wrote in message
news:iuhjh9$8o3$1@cheetah.cadsoft.de...
Morten Leikvoll wrote:
>> May I ask why you need to detect this? Depending on what you try to
>> do, there could be alternative solutions..
>
The need is to provide the correct formatting for the strings passed with
the system() ULP command and the formatting of batch files created by the
ULP and used by the OS script processors.
When the system() command is involved it appears to be most common
(easier)
for a ULP to be crafted solely for use with Windows or Linux/Mac. I wish
to
make a ULP that will work in both environments hence the formatting needs
to
be appropriate for the OS in use.
So I guess a platform dependant batch file that takes the same arguments on
all platforms could sort the case?
I guess you can make linux autorun a xxx.bat file (not sure bout mac), and
windows can for sure.
I tried creating a file called test.bat on both (set the x flag on linux),
and I could run them both with "./test.bat" from shell's (I haven't got
linux eagle install, so you may want to try it)
Morten Leikvoll wrote:
"Warren Brayshaw" <warrenbrayshaw@paradise.net.nz> wrote in message
news:iuhjh9$8o3$1@cheetah.cadsoft.de...
>> Morten Leikvoll wrote:
>>
>>> May I ask why you need to detect this? Depending on what you try to
>>> do, there could be alternative solutions..
>>
>>
>> The need is to provide the correct formatting for the strings passed
>> with the system() ULP command and the formatting of batch files
>> created by the ULP and used by the OS script processors.
>> When the system() command is involved it appears to be most common
>> (easier)
>> for a ULP to be crafted solely for use with Windows or Linux/Mac. I
>> wish to
>> make a ULP that will work in both environments hence the formatting
>> needs to
>> be appropriate for the OS in use.
So I guess a platform dependant batch file that takes the same
arguments on all platforms could sort the case?
I guess you can make linux autorun a xxx.bat file (not sure bout
mac), and windows can for sure.
I tried creating a file called test.bat on both (set the x flag on
linux), and I could run them both with "./test.bat" from shell's (I
haven't got linux eagle install, so you may want to try it)
Thanks for the input Morten:
The thread has moved away from my request for methods to detect the
operating system from within a ULP.
Further ideas from those with expeience with achieving this would be
appreciated.
Warren
"Warren Brayshaw" <warrenbrayshaw@paradise.net.nz> wrote:
Morten Leikvoll wrote:
>> "Warren Brayshaw" <warrenbrayshaw@paradise.net.nz> wrote in message
>> news:iuhjh9$8o3$1@cheetah.cadsoft.de...
>>> Morten Leikvoll wrote:
>>>
>>>> May I ask why you need to detect this? Depending on what you try to
>>>> do, there could be alternative solutions..
>>>
>>>
>>> The need is to provide the correct formatting for the strings passed
>>> with the system() ULP command and the formatting of batch files
>>> created by the ULP and used by the OS script processors.
>>> When the system() command is involved it appears to be most common
>>> (easier)
>>> for a ULP to be crafted solely for use with Windows or Linux/Mac. I
>>> wish to
>>> make a ULP that will work in both environments hence the formatting
>>> needs to
>>> be appropriate for the OS in use.
>>
>> So I guess a platform dependant batch file that takes the same
>> arguments on all platforms could sort the case?
>> I guess you can make linux autorun a xxx.bat file (not sure bout
>> mac), and windows can for sure.
>> I tried creating a file called test.bat on both (set the x flag on
>> linux), and I could run them both with "./test.bat" from shell's (I
>> haven't got linux eagle install, so you may want to try it)
Thanks for the input Morten:
The thread has moved away from my request for methods to detect the
operating system from within a ULP.
Further ideas from those with expeience with achieving this would be
appreciated.
Yea I know I branced off the main topic, but when I thought about it a
couple of times I lean to that the optimal place to do it is outside eagle.
Sounds cleanest to me in any case.
On 6/29/2011 12:33 PM, Andreas Weidner wrote:
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
isn't there a way to run the shell window minimized in windows? i think
a shortcut that is declared to be minimized and just passes args to
cmd.exe would do the trick.
i think it is also possible to run a program in windows completely
invisibly but it can't be done from the OS interface, you have to hex
the shortcut file. it's documented but i haven't had much luck with it.