"system info" returns "missing value" for "IPv4 address"

My script:

results in:

Why is the IPv4 address info missing?



Model: iMac (21.5-inch, Mid 2014)
AppleScript: 2.4
Browser: Firefox 49.0
Operating System: Mac OS X (10.10)

Here, running 10.12, IPv4 is correctly returned.

Yvan KOENIG running Sierra 10.12.0 in French (VALLAURIS, France) mercredi 5 octobre 2016 23:29:52

Are you running an IPv6 only network? Then IPv4 is missing value.

No, I’m on an IPv4-only network.

And /sbin/ifconfig and About This Mac / System Report / Network / Ethernet and System Preferences / Network / Ethernet all show the IPv4 data I’d expect to see on this Mac.

The system info command was written in the days when Macs generally had only one IP address. Nowadays they tend to have many, and I don’t think there’s any guarantee which one the command returns. It may well be trying to return the address of another interface that does have an IPv6 address, as DJ suggested.

You can get all the addresses like this (it takes several seconds):

use framework "Foundation"
current application's NSHost's currentHost()'s addresses() as list

There’s also an option to get a single address:

use framework "Foundation"
current application's NSHost's currentHost()'s address() as text

Interestingly, the documentation for the latter says " arbitrary choice".

Thank you for the reply, Shane.

When I paste the two lines you provided:

and run it, I get a syntax error - “Expected end of line, etc. but found property.”, and after clicking OK the word “name” in the “set compname to host NAME…” line is highlighted.

So for another test, I cut everything out of the script except for those two lines, and the script now runs, but nothing shows up in a dialog display, etc (which I rather suspected would be the case, as I suspect “list” is some sort of variable that has to then be displayed to the user in some way), but in the “Result” box at the bottom of the screen I get some IP info, which will take a bit of massaging with awk, etc, (whatever the Applescript method is), to get what I want, but looks like it may be usable.

Then I tried the other option you mentioned:

and in the Result box got this:

Interesting that the IPv4 address is not provided here either, and as you say, the result is arbitrary.

The conclusion I’m coming to is that Applescript does not provide an easy, reliable way of getting the computer’s IP address, which is the whole reason I was trying to go the Applescript route rather than just using a bash script (the latter of which wouldn’t entail learning Applescript, and would be more portable, but also doesn’t have a “dialog”-like utility built into OS/X, which makes the GUI part problematic).

BGINFO4X would probably work for what I’m wanting, but it requires extra tools (homebrew and/or something - I forget now), so is not suitable for the task I’m working on.

I think I’ll just give up for now on providing my users with an easy click-and-read method of providing the Helpdesk with their basic info. When I started this, I thought it would be a ten-minute script-writing exercise, but after tinkering with it the better part of two days, I’ve got to leave it for other work that is higher priority.

Thanks for the help, though, everyone. It’ll provide me a few directions to go when next I get it in my head to tackle this task.


What you got is due to the fact that your code is using scripting additions features.
Inserting use scripting additions just after (or just before) the instruction use framework “Foundation” would have solved the problem.

use framework "Foundation"
use scripting additions

current application's NSHost's currentHost()'s addresses() as list

display dialog my recolle(result, linefeed)


on recolle(l, d)
	local oTIDs, t
	set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
	set t to l as text
	set AppleScript's text item delimiters to oTIDs
	return t
end recolle

use framework "Foundation"
use scripting additions

current application's NSHost's currentHost()'s address() as text

display dialog result

Yvan KOENIG running Sierra 10.12.0 in French (VALLAURIS, France) jeudi 6 octobre 2016 15:54:08

I think the following bash script (which I named “WhatIsMyIP?”) will do what I need:


  • Command-Q will verify that you want to close the window; presumably anyone with an already-open Terminal window will realize they may not want to close the app, but only the window. Short of having this script analyze the output of ps and counting instances of Terminal, this is probably the best way to handle closing what this script has opened, trusting that users savvy enough to already have a Terminal instance running won’t shoot themselves in the foot by closing the app entirely.

  • The final “read keypress” is there just to prevent the script from putting an unwanted “logout” on the screen.

  • The “exit 0” would normally never be reached (as the Command-Q would abort the script), but it’s a habit of mine to include such at the end of a script.

  • The script must be made executable (“chmod a+x scriptname”).

  • The script must be configured in Finder to be opened always with Terminal rather than TextEdit (or whatever), in order for the double-click-to-run functionality to work (right-click, “Open with”, “Always open with”).

  • I then put the script in /Applications, give it a new icon (like the one on /Applications/Utilities/System Information - right-click on System Information, “Get Info”; right-click on the new shortcut,“Get info”; put both “Get Info” windows side-by-side; drag the big icon in the Preview section of the System Information window to the top little-icon section of the script’s window; when a plus sign appears, let go of the mouse, and the icon will become the script’s new icon), and then I copy the script to the Dock, in the right-hand panel.



your reply adds to the possible solution. Thanks!

With the info you folks have provided I think I could have made it work, but my bash script does what I need for now (and more intuitively, and faster, with just the disadvantage of not displaying it in GUI format with a simple “OK” to click to close it), so I think I’ll just stick with it, at least for the time being.

But thanks everyone! At least now I know a little more about Applescript, and may find that information invaluable in future tasks.