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.
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
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.
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........
Because of this flashing DOS window I now use Windows Scripting Host (WSH)
which is included in all Windows releases.
It interpretes Visual Basic Script or JavaScript files.
It is a little bit harder to code than a DOS batch as your batches are now
.vbs or .js files.
I went the vbScript route as it was little easier to get grips with it
with more examples on the web. That said I think JavaScript is more ULP like
Performance is great when displaying a pdf and the flashing command window
does not exist. The calling Eagle app is only locked until wscript gets
going which is very short.
The ULP line calling the test1.vbs file with wscript
system("wscript \"J:
WINDOWS
Desktop
test1.vbs\"");
Contents of test1.vbs
Set objShell = CreateObject("WScript.Shell")
objShell.Run chr(34) & "J:\WINDOWS\Desktop\MyPdf.pdf" & chr(34),1
Set objShell = nothing
WScript.Quit
Enjoy
Warren