Page 1 of 1

OSX app started from commandline

Posted: Tue May 29, 2018 11:40 pm
by mimu
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'

Re: OSX app started from commandline

Posted: Wed May 30, 2018 9:57 am
by pv479953
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).

Re: OSX app started from commandline

Posted: Wed May 30, 2018 10:38 am
by mimu
Excuse me, his hint doesn't help.

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