Getting machine creation date without the System Profiler?

I need to be able to do this without opening the system profiler. I have been using the terminal window and using a bunch of different commands, but I cannot seem to be able to find the correct command to get the NIC number.

I would even be happy with the machine creation date but I cant seem to get that either. I am trying to use code such as: /sbin/ifconfig but I am still struggling.

Any help would be greatly appreciated!

In Kindness
Stephen K Knight

Maybe you can use parts of this code.

– Rob

I know you said you can’t use system profiler but you didn’t specify whether that means you can’t use the GUI system profiler or the command line system profiler. You can use the command system_profiler in a terminal and get all the stats you are looking for. Maybe that will help.

-john

I apologize for not making myself clear. Hear is exactly what I am trying to do.

From FileMaker Pro, I need to be able to call a script that opens the terminal window, minimized, finds the Nic number of the computer, save the nic number as a .txt document, so I can parse it and export it into FileMaker Pro, and then close the terminal window.

I have had so many problems trying to grab information using the Apple System Profiler and the System Profiler, I was hoping that I could just grab the information from the terminal and save what i needed to text and then import that into FileMaker.

Hopefully I explained it a little better.

In Kindness
Stephen

ifconfig | grep ether | awk '{print $2}'

so, something like

set x to (do shell script "ifconfig | grep ether | awk '{print $2}'")

should do the trick. just inject that variable into your FM database. i don’t know anything about FM’s scripting syntax, so i can’t help you.

this way, there’s no need to write to a file or parse or open a terminal window or anything like that. there’s probably an even shorter command to do the same thing. this one should work as long as the ethernet interface is the only one you need. grep for something else if you need something different.

Thank you for your reply. I tried running the following line of code in the terminal window on OSX.

ifconfig | grep ether | awk '{print$2}'

The result is
usage: ifconfig interface address_family [address[dest_address]][parameters]
and then it gives me a series of choices such as ifconfig -a, etc.

Please let me know how to progress from here.

In kindness,
Stephen

you need to specify an interface, apparently. it worked fine for me.

assuming you have one NIC card and the default is assigned to en0, try this:

ifconfig en0 | grep ether | awk '{print$2}'

type ifconfig in the terminal and see which interfaces you get and what they’re called. ifconfig with no options should give you data for all interfaces.

which version of OS X are you running? i’m pretty sure ifconfig behaves the same across all the available builds.

the code

ifconfig en0 | grep ether | awk '{print$2}'

works great in the terminal window! Thank you! Here is my delima. I need to pass this information to FileMaker. I am currently running OXS 10.1.

Everytime I run the applescript editor it freezes on the words. “shell script” and throws up this error “Expected “,” but found identifier instead.”

Applescript does not seem to allow me to run shell scripting?

Is there a way to run the terminal window using applescript, have it use

ifconfig en0 | grep ether | awk '{print$2}'

and save that as a text file? and then I can import that into FileMaker? Because I cannot seem to get Applescript to go past any code that I try to run it stalls every time it gets to the word “shell” in any of my scripts.

Thank you everyone for your help!
In Kindness
Stephen

i don’t remember what the syntax is in OS X 10.1, but you can try checking out some scripting additions to help you issue shell commands.

look at these: http://osaxen.com/modules.php?op=modload&name=osaxen&file=index&keywords=shell

i also don’t think you need to save this data to a text file, but i don’t know much about filemaker’s syntax.

good luck!

This uses a very slightly modified version of Greg Spence’s IP Address script (though you still need to be able to run a “do shell script” command):

set {ip_external, ip_internal, MAC_add} to my get_address_info()

tell application "FileMaker Pro"
    tell current record of database 1
        --change the cell names to match your database
        set cellValue of cell "ip_external" to ip_external
        set cellValue of cell "ip_internal" to ip_internal
        set cellValue of cell "MAC_add" to MAC_add
    end tell
end tell

on get_address_info()
    try
        set ip_external to word -6 of (do shell script "curl http://checkip.dyndns.org")
    on error
        set ip_external to "?unknown?"
    end try
    set the_interface to 0
    repeat
        set ip_internal to do shell script ("/sbin/ifconfig en" & the_interface & " | head -3 | grep 'inet ' | cut -d' ' -f 2")
        set MAC_add to do shell script "ifconfig en" & the_interface & " | grep ether | cut -b "7-24""
        if ip_internal is not "inet" then exit repeat
        set the_interface to the_interface + 1
        if the_interface is greater than or equal to 5 then
            set {ip_internal, MAC_add} to {"?unknown?", "?unknown?"}
            exit repeat
        end if
    end repeat
    return {ip_external, ip_internal, MAC_add}
end get_address_info

Jon

Here’s a version that uses the Terminal but I’m not sure Terminal in Mac OS 10.1 is scriptable:

set {ip_external, ip_internal, MAC_add} to my get_address_info_with_terminal()

tell application "FileMaker Pro"
    tell current record of database 1
        --change the cell names to match your database 
        set cellValue of cell "ip_external" to ip_external
        set cellValue of cell "ip_internal" to ip_internal
        set cellValue of cell "MAC_add" to MAC_add
    end tell
end tell

on get_address_info_with_terminal()
    set the_interface to 0 --0 is for ethernet, change to 1 for AirPort, etc.
    tell application "Terminal"
        do script "curl http://checkip.dyndns.org"
        delay 5 --may need to adjust on systems with a slower connection
        do script "/sbin/ifconfig en" & the_interface & " | head -3 | grep 'inet ' | cut -d' ' -f 2" in window 1
        delay 1
        do script "ifconfig en" & the_interface & " | grep ether | cut -b "7-24"" in window 1
        delay 1
        set the_result to contents of window 1
        try
            quit
        end try
    end tell
    repeat with i from 1 to (count of paragraphs of the_result)
        set this_para to paragraph i of the_result
        if this_para starts with "<html><head><title>Current IP" then
            set ip_external to word -6 of this_para
            set ip_internal to paragraph (i + 2) of the_result
            set MAC_add to paragraph (i + 4) of the_result
            return {ip_external, ip_internal, MAC_add}
        end if
    end repeat
    return {"?unknown?", "?unknown?", "?unknown?"}
end get_address_info_with_terminal

Jon

You’ll have to update to at least OS X 10.1.2 (which equates to AppleScript version 1.8.1), in which the “do shell script” feature was added to AppleScript.

Hope this helps…