Getting the Computers 'name' on a Mac and Windows

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Getting the Computers 'name' on a Mac and Windows

Post by andyh1234 » Thu Aug 12, 2010 10:37 pm

Is there a quick way to get the computers name on a mac and windows (and potentially linux) with rev?

I dont really want to go down the executing vbscript or applescrip t route as its just a small detail in an app im working on to sync a database between a few computers, and it would be neat to pre-fill the computer name in a form field as a suggestion for the user when they are initially setting up the sync.

I just wondered if there was a simply system style var in runrev that would give me access to this so I can pop it in the field when the card opens.

Thanks

Andy

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by mwieder » Thu Aug 12, 2010 11:31 pm

Yep.

OSX (and possibly linux distros):
put shell("echo $HOSTNAME")

Windows:
put $COMPUTERNAME

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by andyh1234 » Thu Aug 12, 2010 11:34 pm

Thanks Mark,

I had tried put $COMPUTERNAME on my mac, I didnt think it might be different cross platform!

Ill use...

if the platform is "Win32" then
put $COMPUTERNAME into tComputerName
else
put shell("echo $HOSTNAME") into tComputerName
end if

That should work a treat!

Thanks again.

Andy

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by mwieder » Fri Aug 13, 2010 12:27 am

Yeah - I tried viewing the $ environment variables with the message box (click on the fourth icon) but it didn't show anything useful, so I brought up a terminal window and typed "set" to see what was available.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by trevordevore » Fri Aug 13, 2010 8:12 pm

On Mac you could just use 'the hostname' property in Rev. 'the hostname' may return the same value as $computername on Windows as well though I haven't tested.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by mwieder » Fri Aug 13, 2010 8:40 pm

Trevor-

Good catch. Both the hostname and $COMPUTERNAME return the same value on Windows, although if it matters, hostname is in lowercase and for some reason $COMPUTERNAME is in uppercase.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting the Computers 'name' on a Mac and Windows

Post by bn » Sat Aug 14, 2010 12:31 am

Trevor,
a bit off topic: today I searched for your wonderful enhancedQT external and eventually found it.
The link you currently have in your post to your developer resources
Releasable Revolution: Resources for Application Developers
is broken.

Thanks again for all the help and resources you provide

regards
Bernd

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by trevordevore » Sat Aug 14, 2010 9:33 pm

Thanks Bernd. It is back up now.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting the Computers 'name' on a Mac and Windows

Post by bn » Mon Aug 16, 2010 3:36 pm

Trevor,

sorry to bug you, but the link in your 'tag' is still broken.

So are the download links on
http://knowledgefaucet.com/developer/re ... cedqt.html

I was trying to direct someone to that link and did not notice that the download links are broken.

It would be a pitty if people could not reach your wonderful resources for Revolution.

Thank you
regards
Bernd

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Getting the Computers 'name' on a Mac and Windows

Post by trevordevore » Mon Aug 16, 2010 3:54 pm

I just tested the link in my signature and it works fine. The link you posted is not the actual site. That looks like an old version of the site from some time ago.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting the Computers 'name' on a Mac and Windows

Post by bn » Mon Aug 16, 2010 5:11 pm

Trevor,

thanks, after emptying the cache of my browser the link works. Sorry about that.

Now your resources are easy to find.

regards
Bernd

Post Reply