SQL Question

Discussion in 'Mac Programming' started by bigMAC28, Aug 2, 2013.

  1. macrumors member

    Joined:
    Apr 16, 2012
    Location:
    Chicago
    #1
    Hi guys,

    Is it possible to write a script that pulls basic computer info (Name,PC Model Number, Processor speed) that will run when a machine is imaged using pxe boot, then update the database using said information?
     
  2. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #2
    Just split it into a few parts:

    Code:
    $ sysctl machdep.cpu.brand_string
    machdep.cpu.brand_string: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz
    
    $ echo $HOSTNAME
    Bill-iMac.local
    
    $ sysctl hw.model
    hw.model: MacBookAir4,1
    
    I'll leave it up to you to decide how you want to put that into a SQL database. Store them as variables in a bash script and then just upload them with an INSERT statement, running from a MySQL command prompt.
    Code:
    mysql -e "use database_name; insert into table_name values (...);"
    
     
  3. macrumors 6502a

    Joined:
    Jun 17, 2003
    #3
    Another source for the data is:

    Code:
    $ system_profiler SPHardwareDataType SPSoftwareDataType
    It is possible to write code to do this when a machine PXE boots. You'll need to work out where to host the database. This is probably easiest to achieve by creating a custom Linux boot image and then deploy that image on a PXE server. But this is quite a bit more work than just writing a script.
     

Share This Page