OSX app started from commandline

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mimu
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 76
Joined: Tue Mar 05, 2013 7:00 pm
Location: Berlin
Contact:

OSX app started from commandline

Post by mimu » Tue May 29, 2018 11:40 pm

Hello, dear livecoders i need some help.
At the end i’am trying to write a small app which will be started from the osx command line with a phone number as parameter, asking an internal web service for details about this number.

After compiling my app as a standalone for osx it works like expected if i start it with double-click in finder.

When i’am starting it from command line using this command:
open -a '/Users/mimu/Desktop/cmParamTest/cmParamTest.app' --args '015115676045'

The app opens, the parameter is written to a field. But posting to my webservice fails.

To track things down i tried a couple of things:
1.
a Button with this script:
on mouseUp
put field "urlAddress" into tUrl
put url tUrl into field "webpagetext"
end mouseUp

works if standalone app started with double-click in finder, clicking this button nothing happens when app started from commandline

2.
another button with this script to check the loaded extensions:
on mouseUp
answer the loadedExtensions
end mouseUp

- app started in finder, i get an answer dialog listing the loaded Extensions.
- app started from commandline i get the following messagewindow:

Do you want to save changes to stack „cmParamTest“ and all other stacks in the file „cmParamTest.livecode“ before closing.

What i’am doing wrong?

using Livecode 9 business, on osx 10.13

Little test stack attached

standalone inclusions: Internet, JsonLib, tsnet
compile it and start from commandline:
open -a '/Users/username/Desktop/test/MacOSX/test.app'
Attachments
test.livecode.zip
(1.76 KiB) Downloaded 184 times

pv479953
Posts: 1
Joined: Wed May 30, 2018 9:16 am

Re: OSX app started from commandline

Post by pv479953 » Wed May 30, 2018 9:57 am

An application bundle (a .app file) is actually a bunch of directories. Instead of using open and the .app name, you can actually move into it and start the actual binary. For instance:

$ cd /Applications/LittleSnapper.app/
$ ls
Contents
$ cd Contents/MacOS/
$ ./LittleSnapper
That is the actual binary that might accept arguments (or not, in LittleSnapper's case).


That is the actual binary that might accept arguments (or not, in LittleSnapper's case).

mimu
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 76
Joined: Tue Mar 05, 2013 7:00 pm
Location: Berlin
Contact:

Re: OSX app started from commandline

Post by mimu » Wed May 30, 2018 10:38 am

Excuse me, his hint doesn't help.

The main problem is that the externals and even networking is not loaded. (when started von commandline)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”