• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: One more thing...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One more thing...


  • Subject: Re: One more thing...
  • From: "Mark J. Reed" <email@hidden>
  • Date: Tue, 24 Aug 2010 16:34:29 -0400

Well, you can get a list of interfaces with something like this:

set interfacesList to paragraphs of (do shell script "ifconfig | awk
-F: '/^[^\\t]/ {print $1}'")

And then you can loop through them and try to get their addresses:

set interfacesList to (paragraphs of (do shell script "ifconfig | awk
-F: '/^[^\\t]/ {print $1}'"))
set addressesList to {}
repeat with i from 1 to count interfacesList
    set ifName to (get item i of interfacesList)
    try
        set ipAddr to (do shell script ("ipconfig getifaddr " & ifName))
        set end of addressesList to {(get ifName), ipAddr}
    end try
end repeat
addressesList

The above is far from optimally efficient; you could get all the
necessary data by running a single 'do shell script "ifconfig"' and
just parsing the resulting output - but it's relatively
straightforward.

Note, I had to do the repeat as a count and do a "get" into ifName,
instead of just "repeat with ifName in interfacesList" because the end
result always had "item 6 of lo0, gif0, stf0, en0, fw0, en1, en2, en3"
in place of "en1", even if I used "get ifName".  Seems buggish.

On Tue, Aug 24, 2010 at 4:05 PM,  <email@hidden> wrote:
> Several months ago with the help of several posts here I developed this
> little script that gives general information about a Mac to aid a remote
> help support person. I have run into a little snag with some recent field
> testing and that is the script is looking specifically at en0 if you are
> using en1 you get the error: get if addr en0 failed (os/kern) failure.
>
> What is the best way to check both ports or 0 and then 1 if there is no
> cable in 0 or all possible cards and then just reporting back what it finds?
> Thanks for all your help once again!
>
> set macInfo to system info
> set macName to computer name of macInfo
> set ipAddress to do shell script "ipconfig getifaddr en0"
> set userName to long user name of macInfo
> set shortUserName to short user name of macInfo
> set hostName to host name of macInfo
> set userlocale to user locale of macInfo
> set bootvolume to boot volume of macInfo
> set homeDirectory to home directory of macInfo
> set systemVersion to system version of macInfo
> set primaryEthernetAddress to primary Ethernet address of macInfo
> set CPUtype to CPU type of macInfo
> set CPUspeed to CPU speed of macInfo
> set Physicalmemory to physical memory of macInfo
> set homeDirecory to home directory of macInfo
> set networkInfo to do shell script "/usr/sbin/system_profiler" -- get
> network info
> set AppleScript's text item delimiters to {"Domain Name:"}
> try (* get rid of unavailable domain *)
>         set macDomainName to paragraph 1 of text item 2 of networkInfo
> on error
>         set macDomainName to "unknown"
> end try
> set AppleScript's text item delimiters to {" "}
>
> set userInfo to {}
> set the end of userInfo to {"~HELP DESK INFORMATION~"}
> set the end of userInfo to {"Computer Name:", macName} as text
> set the end of userInfo to {"IP Address:", ipAddress} as text
> set the end of userInfo to {"Network Domain:", macDomainName} as text
> set the end of userInfo to {"User Name:", userName} as text
> set the end of userInfo to {"Short User Name:", shortUserName} as text
> set the end of userInfo to {"Host Name:", hostName} as text
> set the end of userInfo to {"User Location:", userlocale} as text
> set the end of userInfo to {"Boot Volume:", bootvolume} as text
> set the end of userInfo to {"Home Directory:", homeDirectory} as text
> set the end of userInfo to {"System Version:", systemVersion} as text
> set the end of userInfo to {"MAC Address:", primaryEthernetAddress} as text
> set the end of userInfo to {"CPU Type:", CPUtype} as text
> set the end of userInfo to {"CPU Speed:", CPUspeed} as text
> set the end of userInfo to {"Memory:", Physicalmemory} as text
>
> set AppleScript's text item delimiters to return
>
> set user_info to userInfo as text (* required to get rid of a confusion upon
> 'as *)
> display alert user_info buttons {"Copy To Clipboard", "OK"} default button
> "OK"
> if button returned of result = "Copy To Clipboard" then
>         set the clipboard to user_info
> end if
>
>
> Jeffrey Madson / RR Donnelley Desktop Engineering
>
>
>
>
>
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>



--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: One more thing...
      • From: "Mark J. Reed" <email@hidden>
References: 
 >One more thing... (From: email@hidden)

  • Prev by Date: One more thing...
  • Next by Date: Re: One more thing...
  • Previous by thread: One more thing...
  • Next by thread: Re: One more thing...
  • Index(es):
    • Date
    • Thread