simple console app with string as return

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

Post Reply
harald.schlager
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 16
Joined: Mon May 09, 2011 3:01 pm

simple console app with string as return

Post by harald.schlager » Tue Oct 15, 2013 7:49 pm

hi all !

I need to write a simple console app but I have troubles ..

todo: on the terminal you start an app with parameters on win/linux/mac and get back as return a string:

foo parameter1 parameter2 parameter3 parameter4

return should be maybe "secret".

so the question is, how to do this in livecode ? how you return a string as return code ? I did not find any sample and my tests only open a stack window on mac or freeze on mac
and linux ! Should be the code in openstack or in startup or ...

thank you in advance,
harald

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: simple console app with string as return

Post by FourthWorld » Tue Oct 15, 2013 7:59 pm

harald.schlager wrote:Should be the code in openstack or in startup or ...
Startup. When running facelessly stacks are never "opened" per se, so AFAIK "startup" is the only message you'll get.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

harald.schlager
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 16
Joined: Mon May 09, 2011 3:01 pm

Re: simple console app with string as return

Post by harald.schlager » Tue Oct 15, 2013 8:31 pm

thank you, when i put in the startup message "return "secret"" and when i start with "open -g x.app" I get nothing back, when I put "put dddd" inside - nothing returns - also when i redirect it in a log file

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: simple console app with string as return

Post by FourthWorld » Tue Oct 15, 2013 9:16 pm

"return" won't do anything, since there's no LiveCode script calling it to return anything.

"put" should work, but perhaps you'll need to call the app directly rather than through the "open" command (that is, just run the app name in Terminal).
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

harald.schlager
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 16
Joined: Mon May 09, 2011 3:01 pm

Re: simple console app with string as return

Post by harald.schlager » Wed Oct 16, 2013 5:58 am

the only command in the startup handler is put "secret" and quit. i call it with the -ui option

windows: no output put quits correctly
linux: invalid pointer at quit, without quit the app did not stop (waiting for input ... )
harald@harald-ubuntu:~/pwkeep$ ./pwkeep -ui
secret
*** glibc detected *** ./pwkeep: munmap_chunk(): invalid pointer: 0x0828ae64 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xce2ee2]
/lib/i386-linux-gnu/libc.so.6(+0x765c5)[0xce35c5]
./pwkeep[0x82516b5]
./pwkeep[0x8052683]
./pwkeep[0x811d42e]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xc864d3]
mac: when i call it directly it works correctly
Harald-Schlagers-MacBook-Pro-9:MacOS haraldschlager$ ./pwk -ui
secret

maybe on linux and windows is a bug ?

Post Reply