a little script to display basic information to an end user. Problem!!

Hi
I’m trying to produce a little script to display basic information to an end user which would be helpful when calling the help desk.
Here’s what I’ve got so far:



tell application "System Events"
	set CompName to (name of computer)
	set CrntUsr to (name of current user)
end tell

set IPAD to do shell script "ipconfig getifaddr en1"

display dialog "Your IP address is: " & return & IPAD & return & return & ¬
	"You computer name is: " & CompName & return & return & ¬
	"You are logged in as: " & CrntUsr & return & return

It all seams to work except when I’m asking for the computer name.
Can anyone spot the problem?

OSX 10.4.9 - Intel

Hi santos,

name of computer is not in System Event’s dictionary.
Use some properties of system info instead (works only on Tiger)

set {computer name:CompName, long user name:CrntUsr} to system info
set IPAD to do shell script "ipconfig getifaddr en1"
display dialog "Your IP address is: " & return & IPAD & return & return & ¬
	"You computer name is: " & CompName & return & return & ¬
	"You are logged in as: " & CrntUsr & return & return

You can also use short user name instead of long user name

Ahh thats different, I’ve always used system events to set the current user name etc.

Nice Thank you.

I’ve also just worked out how to do it anotherway:

tell application "System Events"
	set CrntUsr to (name of current user)
end tell

set IPAD to do shell script "ipconfig getifaddr en1"

set CompName to (do shell script "hostname")


display dialog "Your IP address is: " & return & IPAD & return & return & ¬
	"You computer name is: " & CompName & return & return & ¬
	"You are logged in as: " & CrntUsr & return & return

But I think I will experiment more with your version.

Thanks again StefanK

Do you need to handle en0 as well?

My comment as well, Mike. en0 is my active IP connection.

I would do it this way:

set {computer name:CompName, long user name:CrntUsr} to system info
set IPAD to "not available"
repeat with i from 0 to 5
	try
		set IPAD to (do shell script "ipconfig getifaddr en" & i) & " (en" & i & ")"
		exit repeat
	end try
end repeat
display dialog "Your IP address is: " & return & IPAD & return & return & ¬
	"You computer name is: " & CompName & return & return & ¬
	"You are logged in as: " & CrntUsr & return & return