element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Autodesk EAGLE
  • Products
  • More
Autodesk EAGLE
EAGLE User Support (English) Determine OS from within ULP
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Autodesk EAGLE to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 178 subscribers
  • Views 1149 views
  • Users 0 members are here
Related

Determine OS from within ULP

Former Member
Former Member over 14 years ago

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

 

 

 

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    Former Member over 14 years ago

    "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.

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    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.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    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

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    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

     

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    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

     

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube