Re: Newbie questions about modifying a script.
Re: Newbie questions about modifying a script.
- Subject: Re: Newbie questions about modifying a script.
- From: "Stockly, Ed" <email@hidden>
- Date: Fri, 07 Aug 2009 13:21:31 -0700
- Thread-topic: Newbie questions about modifying a script.
Title: Re: Newbie questions about modifying a script.
Jeffrey,
This script sounds like a really good idea. I may steal it from you : )
Your post touches on several issues that are fairly easy to deal with. (*It also revealed a bug that was new to me!)
First, the Mac OS isn’t really designed to display windows with info on the desktop. Applications do that and several are available, including Text Edit which should be on any mac. However, for your purposes, I ‘m thinking that an applescript dialog will do the trick.
Next, many of the items you’re using shell scripting for are available to plain vanilla applescript with no additional parsing needed.
Third, I couldn’t get the url for checking IP addresses to work. Ideally you should be able to use whatever shell that works in the terminal to work in your script, but that’s something for you orsomeone else to work with.
Lastly, I suggest text item delimiters to parse the results of your shell scripts.
So here’s an example that does about 90% of what you want and should point you in the right direction for the rest.
--Computer Name, IP Address, Domain and User Name of the Mac Work Station
set macInfo to system info
set macName to computer name of macInfo
set macIpAddress to IPv4 address of macInfo
set userName to long user name of macInfo
set networkInfo to do shell script "/usr/sbin/system_profiler SPNetworkDataType" -- get network info
set AppleScript's text item delimiters to {"Domain Name:"}
set macDomainName to paragraph 1 of text item 2 of networkInfo
set AppleScript's text item delimiters to {" "}
set userInfo to {}
set the end of userInfo to {"Computer Name: ", macName} as text
set the end of userInfo to {"IP Address: ", macIpAddress as text} 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 AppleScript's text item delimiters to return & return
display dialog userInfo as text
--*display alert userInfo as text
HTH,
ES
*Is this a bug? If you uncomment that last line, it generates an error. It shouldn’t.
On 08/07/09 11:03 AM, "email@hidden" wrote:
Good Afternoon,
I am totally new to AppleScript and need some assistance/advice on a script I'm trying to develop. I want to end up with a Application in the Dock or Menu Bar Item that will display the Computer Name, IP Address, Domain and User Name of the Mac Work Station in a window on the desktop.
_______________________________________________
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