Mac - Computer Name - Omnis 11.1 - OS Sequoia

Mike Matthews - Omnis omnis at lineal.co.uk
Fri Oct 4 07:54:27 UTC 2024


Hello Joe,

We do the same, get a socket, and then ask. The only fly in the proverbial is when you have no internet connection, then there is a short delay from memory.

Looking forward to catching up with you and the rest of the Omnis community (you are all coming aren't you?) at www.euromnis.com<http://www.euromnis.com> this November, just 5 weeks time.

Thanks

Mike Matthews

Lineal Software Solutions
Commercial House, The Strand<x-apple-data-detectors://1/1> Barnstaple, Devon, EX31 1EU<x-apple-data-detectors://1/1>

omnis at lineal.co.uk<mailto:mike.matthews at lineal.co.uk>

www.lineal.co.uk<http://www.lineal.co.uk/>

www.sqlworks.co.uk<http://www.sqlworks.co/>



On 4 Oct 2024, at 00:17, Joe Maus <jmaus at theccgllc.com<mailto:jmaus at theccgllc.com>> wrote:

Caution: This is a message which has originated from outside the organisation. Ensure the sender is trusted and the content is safe before opening links or attachments.



Hi,

I know the original question was about how to get the machine name but it's morphed into something a little more than that so I thought I'd share how I usually get the IP of the machine's internet aware NIC.  I've used this on a Mac or windows machine with good success. But I'll also marry it with some additional scripts (some already covered here) to get the listing of the interfaces in the machine to see if en0 matches the IP given by the below code, if it does, then we're pretty sure that's the primary interface for the machine.

TCPConnect ('www.google.com<http://www.google.com>',80) Returns sock
TCPGetMyAddr (sock,kFalse) Returns lvTCPMyAddrIs
TCPClose (sock,0)

Might be useful if you changed google.com<http://google.com> to point to the local server you're looking for and see if that returns the IP of the NIC that can see it.

Thought it might be helpful

Joe Maus

On Oct 3, 2024, at 4:57 PM, Michael Mantkowski <michaelj at clientrax.com<mailto:michaelj at clientrax.com>> wrote:

BTW...

Phil's code to get the local IP does work. Just having issues with the Omnis TCP commands.

Calculate lcApScript as 'set myip to do shell script "'
Calculate lcApScript as con(lcApScript,"ifconfig | grep 'broadcast' | awk '{print $2}'")
Calculate lcApScript as con(lcApScript,'"')
Do $runapplescript(lcApScript,lcIP_Address)
If pos(kCr,lcIP_Address)
Calculate lcIP_Address as mid(lcIP_Address,1,pos(kCr,lcIP_Address)-1)
End If
Do replaceall(lcIP_Address,'"','') Returns lcIP_Address

*********************************************************************
Michael Mantkowski
ClienTrax Software
1-614-875-2245
*********************************************************************


-----Original Message-----
From: omnisdev-en On Behalf Of Michael Mantkowski
Sent: Thursday, October 3, 2024 4:41 PM
To: 'OmnisDev List - English' <omnisdev-en at lists.omnis-dev.com<mailto:omnisdev-en at lists.omnis-dev.com>>
Subject: RE: Mac - Computer Name - Omnis 11.1 - OS Sequoia

With this command...

   TCPGetMyAddr Returns iLocalIPAddress

I always get "127.0.0.1" on the Mac - Should be "192.168.1.246" (As shown in the System Settings / Network / Ethernet window)

On Windows Omnis 11.1 it always returns the proper IP Address.


The earlier code for getting the computer name works great. In this case "Michael's Mac mini" However,

   TCPName2Addr (ctComputerName) Returns #S1

Always returns "0" in the Mac.

On Windows it returns the proper IP Address.

Any ideas on these?

*********************************************************************
Michael Mantkowski
ClienTrax Software
1-614-875-2245
*********************************************************************


-----Original Message-----
From: omnisdev-en On Behalf Of Doug Easterbrook via omnisdev-en
Sent: Thursday, October 3, 2024 11:15 AM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com<mailto:omnisdev-en at lists.omnis-dev.com>>
Cc: Doug Easterbrook <doug at artsman.com<mailto:doug at artsman.com>>
Subject: Re: Mac - Computer Name - Omnis 11.1 - OS Sequoia

hi Michael.

I know that the question starts with getting the computer name…..   but then the side track seems to really be about getting the ip address of the computer



I use two ways to get the local ip address of the machine on OSX

the built in method — which returns the primary IP address and is usually correct

TCPGetMyAddr Returns iLocalIPAddress


OR if I want more, I use Kelly Burgess’s TCP tools to grab the list of interfaces, and what it thinks is the local ip address.

Calculate iInterfaceList as TCPTools.$interfacelist() Calculate iLocalIPAddress as TCPTools.$localip()

The first command will return you all active interfaces, from ether net card, to wifi, to VPN’s that are available to the computer since things can be multi homed these days.

Trouble is with getting the machines IP address these days, is that each machine may have many, and they can be ipv4 or ipv6




As far as the getEnv command goes, it still works as we use it to get the home directory for mac and windows.     You can see what values are available if you go into the terminal and type ‘env’.


turns out 'ComputerName’ is no longer one of those things.    The following command will get you the computer name in terminal.



scutil --get LocalHostName

All you have to do is wrap that in applescript if you want it as below (I just verified in on my sequoia machine with studio 11.2)

Calculate applescript as 'do shell script "scutil --get LocalHostName" '
Do $runapplescript(applescript,result,errorText)





I know you have a specific reason for doing this.    Since you are sending it a server, I’m guessing it is to track users, logins or what have you.   Depending on the back end database you are using (eg postgres), there are ways to get this from the server itself.








Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.artsman.com&c=E,1,_KASabP7kcgFic8KKpLo6uEJUXTm-VPvdyqt3J0yVZPHTZMteDr3afjvgRaU30VwYM3PxJt_FdahUaEyIfgKt1VPXlqMHYvdquwljowtR2d_Lw,,&typo=1
Phone (403) 650-1978

On Oct 3, 2024, at 6:56 AM, Michael Mantkowski <michaelj at clientrax.com> wrote:

Thanks Phile and Nigel,

I will try this and report back.

Michael

*********************************************************************
Michael Mantkowski
ClienTrax Software
1-614-875-2245
*********************************************************************


-----Original Message-----
From: omnisdev-en On Behalf Of Phil (OmnisList)
Sent: Thursday, October 3, 2024 9:54 AM
To: omnisdev-en at lists.omnis-dev.com
Subject: Re: Mac - Computer Name - Omnis 11.1 - OS Sequoia

Michael,

Begin text block
Text:computer name of (system info)
Get text block lvScript
Do $runapplescript(lvScript,lcComputerName)

or for an IP address:

Calculate lcApScript as 'set myip to do shell script "'
Calculate lcApScript as con(lcApScript,"ifconfig | grep 'broadcast' |
awk '{print $2}'") Calculate lcApScript as con(lcApScript,'"') Do
$runapplescript(lcApScript,lcIP_Address)
If pos(kCr,lcIP_Address)
Calculate lcIP_Address as mid(lcIP_Address,1,pos(kCr,lcIP_Address)-1)
End If
Do replaceall(lcIP_Address,'"','') Returns lcIP_Address


regards
Phil Potter
Based in Chester in the UK.

On 03/10/2024 13:48, Michael Mantkowski wrote:
We upgraded one of our Mac clients to Omnis 11.1 yesterday after they
had
upgraded their Mac OS to Sequoia and Omnis 4.3.2.1 would no longer
work for them.

Running into an issue with getting the computer name of the
workstation
they are on. We had been using the code below to find it. It no longer
seems to work and the built in Omnis getenv() also does not work.

Anyone know how to do this with newer Mac OS version?


f inMac
Do code method CodeClass/RunMacShell ("grep '<key>ComputerName</key>'
/Library/Preferences/SystemConfiguration/preferences.plist -A 1 | grep
'<string>' ") Returns lvReturn
Calculate lvReturn as mid(lvReturn,pos('>',lvReturn)+1)
Calculate ctComputerName as mid(lvReturn,1,pos('<',lvReturn)-1)
Else
Calculate ctComputerName as getenv("COMPUTERNAME") End If


This is all used to eventually get the IP Address of the local
workstation
and the database server so that we can Ping it for online verification.
Since the above fails the Ping Fails as well. I ended up having to
disable the whole server verification to get them running last night.


*********************************************************************
Michael Mantkowski
ClienTrax Software
1-614-875-2245
*********************************************************************



_____________________________________________________________
Manage your list subscriptions athttps://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,xRUwK4c92vVRdkAsnHYtZH1yCnYJ8pp0hV15aoyAQH8r5Jh11r3O4sBisuzIdcDW3a5w5B7cGjHqR7Lj55H1-1Oc3plHR-yYFY6KZRT6m83tKfoZX6ru&typo=1 Start a
new message ->mailto:omnisdev-en at lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,Me9cK_DsPIpMGBJb3EzYmNKp-lZaMMjoiJafhTIL5XsKp-r0Zkrf2PURE7AbojoieXaEUe1q9NpsToT7xdXPNgOt41tWTsm3Dlg9LJvgcObo&typo=1 Start a
new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,umKJZp28fNaESUvxgMlwJAL974S7G5TR1jiwC2VQ97cg0jccDogezytdmxM6ZnSjQgOJ_GjR-_E7SSzodO8lJn2EtvjcIh4yu3nJoYwAsAK77xg,&typo=1 Start a
new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,nJ9rxmhK-zmasAhvK6UE0sxcnF_G7V98FIsenSQE-CoIhVgP029TK2XZ1cnhORbfu_K-V-B-DoK1CIglLD1iIw6L837iFrohtjnNOvqqde0fV_aZ4iIQKG6OCfUi&typo=1 Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,iUuR9Zho-kgsisOvCiXUfIXB7l5ijZNGUvtssMhktKJb2NwUQ-D6FMg2ZE6po2bEHHfz7o-Nmm1WBU-352Cex5VbbCe-I6x43KU1fem3LQrPDe3Q4FoyKLQcsg,,&typo=1 Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,SyA3Kqdd2jhQb2dIf1c96pghWbcZCwUufxGbN1W-PHaHwpaYhG8ec3pazQR7OCd_28_jKuKCNo_7qwXhmJf2j7No156qMG4hWThmzifgAvTMug,,&typo=1
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,1,xdb_hoAwrFDMpHdOcfPkw0KEZP3KFuPuB3EcAcISym0EHdDC5o-Xx-UQlkyOzKamJsYmuV3ZpjVm-sIbA6oQGlettUi744eLIT7udMqbCd2_YCj1ct8,&typo=1
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com



More information about the omnisdev-en mailing list