Operating system code test request...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Operating system code test request...

Post by bogs » Sun May 23, 2021 8:55 pm

I run 'nix, and this works fairly well on that for locating an IP address. I can test this on Windows as well, but what I would like is for a bunch of volunteers to test it out from (hopefully) a lot of individual machines and see if it works for them.

All you should have to do is open the messagebox in the IDE, and put ~

Code: Select all

put shell("curl ipinfo.io")
If it works on your OS, you should see something like this returned -
aPic_shellRequestTest.png
...testing, testing...
I don't need any of the information you see returned !!!!

What I would like to know is -
1. your operating system
2. Lc version ( OPTIONAL )
3. did this work or not ?
4. if it worked, was it complete ?
5. if it worked and was complete, was it accurate? Semi accurate? Complete garbage?

Thank you in advance for testing (and letting me know the results).
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Operating system code test request...

Post by richmond62 » Sun May 23, 2021 9:01 pm

1. your operating system: MacOS 11.5 beta 1
2. Lc version ( OPTIONAL ): 9.6.2 Stable
3. did this work or not ?: worked
4. if it worked, was it complete ?: as far as I can tell.
5. if it worked and was complete, was it accurate? Semi accurate? Complete garbage?

See for yourself:
-
SShot 2021-05-23 at 22.58.07.png

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Operating system code test request...

Post by bogs » Sun May 23, 2021 9:08 pm

Thanks for testing, is "Sofia" accurate? Semi accurate? Close enough for government work? Hee hee.

Let me put it another way, if you were going to list your location for say, a local weather report, is it close enough?
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Operating system code test request...

Post by richmond62 » Sun May 23, 2021 10:40 pm

Sofia is 2 hours away with a mountain range in between.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Operating system code test request...

Post by bogs » Sun May 23, 2021 10:47 pm

Cool shakes, thanks a lot!
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Operating system code test request...

Post by jacque » Mon May 24, 2021 6:20 pm

I get an error on Android. I'm not surprised because Android doesn't allow curl commands from apps, and I suspect iOS doesn't either. I doubt you're planning to build for mobile though.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9834
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Operating system code test request...

Post by FourthWorld » Mon May 24, 2021 7:08 pm

curl is not normally needed in LiveCode.

LC's libURL provides a robust foundation for HTTP, HTTPS, and FTP, in all LiveCode editions, including Community.

tsNet provides more nuanced control for those and a few others, and is the curl library wrapped in the LC externals interface.

libURL can handle the request shown in the OP quite easily with the built-in GET command.

For anything else one needs from curl, tsNet had you covered.

You would only need to call curl from shell if you need some specific functionality beyond HTTP, HTTPS,. and FTP, and will be deploying with the LC Community Edition where the proprietary tsNet external is not included.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Operating system code test request...

Post by bogs » Mon May 24, 2021 7:29 pm

jacque wrote:
Mon May 24, 2021 6:20 pm
I get an error on Android. I'm not surprised because Android doesn't allow curl commands from apps, and I suspect iOS doesn't either. I doubt you're planning to build for mobile though.
I have no doubt you are correct, you certainly are correct in that I have no plans to incorporate or use this knowledge on mobile :D

@Richard -
I had never looked into libUrl, or tsNet, however I did try to look up how you would use it after you mentioned it here.

tsNet is a non-starter for the reason you mentioned...
...deploying with the LC Community Edition where the proprietary tsNet external is not included.
As far as libUrl goes, it appears most of the wrapper commands are longer than the entire shell line is, and while I understand what curl is doing, I'd be less than honest if I said I understood which of the 20 different lines under it ...
Image

would be the equivalent of

Code: Select all

shell("curl ipinfo.io")
...and even if I did know ( I may experiment later ), I would almost have to assume I would get back the same information to parse, so it doesn't look like a code saver from where I am sitting.

Again though, I am unfamiliar with it, what would be the primary advantage to using it over just shell'ing it?

*Edit - I spent time experimenting with the address and libUrlDownloadToFile, and got no information back, so I think I'll probably stick with 'curl'.

*Edit 2 - I didn't see how any of the other libUrl wrappers would even be workable for what I was doing.
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Operating system code test request...

Post by jacque » Mon May 24, 2021 8:18 pm

Mac OS X Mojave: returns my exact city and state.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9834
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Operating system code test request...

Post by FourthWorld » Mon May 24, 2021 8:24 pm

libURL is a special library deeply integrated with the LC engine. The descriptive command names you listed are rarely needed for most common day-to-day tasks.

See the "get url" and "post" commands.

For example, all you need to use native LC for what you've shown in this thread for curl is:

Code: Select all

get url "ipinfo.io"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Operating system code test request...

Post by bogs » Mon May 24, 2021 8:58 pm

jacque wrote:
Mon May 24, 2021 8:18 pm
Mac OS X Mojave: returns my exact city and state.
Beautiful!
FourthWorld wrote:
Mon May 24, 2021 8:24 pm
libURL is a special library deeply integrated with the LC engine. The descriptive command names you listed are rarely needed for most common day-to-day tasks.

See the "get url" and "post" commands.

For example, all you need to use native LC for what you've shown in this thread for curl is:

Code: Select all

get url "ipinfo.io"
Didn't work, in that it returned nothing, and I didn't get anything when I added

Code: Select all

get url "ipinfo.io"; wait 5 seconds with messages; put it
without the wait with messages, I got "error URL is currently loading"

I am pretty familiar with the get command (although I usually just directly 'put' whatever I need). I'm not posting anything in the upwards direction, although I am not that familiar with post (will look into it to see if it is of some use in this case).

In this case, though, it doesn't seem to be as workable as curl. At least, not with what I am looking to do.

Checked 'post', as I assumed it was upwards direction specific.

Did you check that get works for you in this instance? It sure doesn't here.
Last edited by bogs on Mon May 24, 2021 9:01 pm, edited 1 time in total.
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Operating system code test request...

Post by jacque » Mon May 24, 2021 8:59 pm

FourthWorld wrote:
Mon May 24, 2021 8:24 pm
For example, all you need to use native LC for what you've shown in this thread for curl is:

Code: Select all

get url "ipinfo.io"
Should this work on Mac OS X? Maybe the url needs a more specific path?
Edit: The result is "invalid URL".
Last edited by jacque on Mon May 24, 2021 9:07 pm, edited 1 time in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9834
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Operating system code test request...

Post by FourthWorld » Mon May 24, 2021 9:02 pm

My bad: my example didn't include a real url.

Sockets can be used with many protocols, so libURL requires us to use a full URL which of course includes the service specifier up front:

Code: Select all

get url "http://ipinfo.io"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Operating system code test request...

Post by bogs » Mon May 24, 2021 9:05 pm

Richard, I am going to ask you again if you looked at the return when adding the "http" or "https". Please compare that return to what you see in my OP.

I suppose I *could* scrape that and find what I need, but I still don't see how that is better.
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Operating system code test request...

Post by jacque » Mon May 24, 2021 9:13 pm

bogs wrote:
Mon May 24, 2021 9:05 pm
I suppose I *could* scrape that and find what I need, but I still don't see how that is better.
The info you want isn't in there. Instead it returns the front page of an actual web site at URL "http://infoIP.io".

I tried using "localhost" and variations but I'm still missing something. I'm pretty sure it's possible, I just can't find the right combination.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”