SQL Question

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

  1. bigMAC28
    Expand Collapse
    macrumors member

    Apr 16, 2012
    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. robvas
    Expand Collapse
    macrumors 68000

    Mar 29, 2009
    Just split it into a few parts:

    $ sysctl machdep.cpu.brand_string
    machdep.cpu.brand_string: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz
    $ echo $HOSTNAME
    $ 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.
    mysql -e "use database_name; insert into table_name values (...);"
  3. mrichmon
    Expand Collapse
    macrumors 6502a

    Jun 17, 2003
    Another source for the data is:

    $ 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