Page 1 of 2

Console app, output to console?

Posted: Thu Aug 08, 2013 8:50 am
by trenatos
I'm trying to make a console app, it'll run on linux but I'm testing on linux and windows.
In the Dictionary it says that write "Stuff here" to stdout should output the text on the console, but it doesn't work (On Windows nor Linux)
Tried running with -ui, and chmodded to 755 on linux.

On Linux it freezes, I get a new blank line and then nothing, on Windows I get a blank line and the it quits back to prompt.

What am I missing here?

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 3:04 pm
by FourthWorld
I'm surprised stdOut isn't working, but you may try simply "put" without a destination to do that as well, e.g.:

Code: Select all

put "Hello Console"

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:03 pm
by trenatos
That doesn't work either.
I tried putting it in the card script, and the stack script, but nothing outputs.

I've tried with the last version as well as the latest version.

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:06 pm
by FourthWorld
Do you know if the app is even running? Perhaps you could try writing some output to a file to check that.

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:10 pm
by trenatos
Could I ask for a favor?
Can you make a .livecode file that compiles and works with outputting to the console/CLI on your computer, that I can download and look at?

Maybe I'm missing something subtle or silly, it would also let me confirm that it's me and not the LC compiler.

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:11 pm
by FourthWorld
This should work - just put this into the stack script of a standalone and build for Linux:

Code: Select all

on startup
  put "Hello Console"
end startup

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:27 pm
by trenatos
I opened a new stack, put that in and compiled, didn't work on Windows but worked on Linux...
I swear I tried that before and it didn't work..

Thank you, FourthWorld! (Sorry, I can't remember your name, I'm horrible with names..)

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:40 pm
by FourthWorld
trenatos wrote:I opened a new stack, put that in and compiled, didn't work on Windows but worked on Linux...
I swear I tried that before and it didn't work.
Windows is finicky; best left behind to hasten its declining market share. :) (Pardon my Linux fanboyism)

More seriously, sometimes on Win the trick is to set the value of LC's shellCommand global property to the full path of the shell you're using. Let me know if that doesn't do it for you.
Thank you, FourthWorld! (Sorry, I can't remember your name, I'm horrible with names..)
I put it in my sigline to help others as bad with names as I am. :)

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:45 pm
by trenatos
Haha that's what I get for not paying attention, thank you Richard!

Yeah I like Linux better than Windows too, but I also like lots of games on Windows, and most of my clients use it, so there's no escaping it. lol

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 7:54 pm
by FourthWorld
trenatos wrote:Yeah I like Linux better than Windows too, but I also like lots of games on Windows, and most of my clients use it, so there's no escaping it. lol
Just install KDE on their systems and tell 'em it's Windows 9 - all they'll know is it's faster, leaner on resources, more usable, and has as much app compatibility as Win RT. ;)

Keep me posted on how the shellCommand thing works out.

Re: Console app, output to console?

Posted: Thu Aug 08, 2013 9:54 pm
by trenatos
Heh, tempted to do that. lol

So now stdout works on Linux, but it still doesn't work on Windows.

That's not an issue for me, this application is for Linux only, but the Dictionary does say that it should work with Windows, so I may have stumbled on a bug in the latest rc2 release?

Re: Console app, output to console?

Posted: Fri Aug 09, 2013 12:55 am
by trenatos
Hey Richard, since you're a Linux guy and programmer, maybe you could help me out on this one too:
The program I'm making, I'd like it to be able to run in the background, both when run manually and on server boot, any pointers on that?

Re: Console app, output to console?

Posted: Fri Aug 09, 2013 3:04 am
by mwieder
stdout on Windows is weird - the console doesn't count. You can, however, send stderr to the console, IIRC.
Try launching the app from a commandline and redirect the output to a text file.

At any rate, writing to stdout works on linux. Put does not go to stdout.

Re: Console app, output to console?

Posted: Fri Aug 09, 2013 4:00 am
by FourthWorld
mwieder wrote:Put does not go to stdout.
Where does it go?

Re: Console app, output to console?

Posted: Fri Aug 09, 2013 6:15 am
by mwieder
stdout goes to a different pipe on Windows. The console is connected to stderr, but not to stdout. If you redirect the stdout output you can catch it in a file.

Ah. I see I answered a different question from the one you asked.
I'm not sure where put goes. In the IDE it goes to the message box unless it's redirected.
I don't know what happens in a standalone... maybe it's one of those uncaught messages that are trapped by a frontscript in the IDE.