Run console app with its messages showing?

Hello all,

I have a problem with one of my apps. The Raspberry Pi is in England, I am in Phoenix. I want to run the console app so that I can read the ‘print’ commands in an effort to debug.

I know how to run the app from a terminal, but I never get the ‘window’ to read the print statements (I have them in there to try to find the problem).

Any help would be really appreciated!

Tim

I thought this info from xojo documentation would help:
https://documentation.xojo.com/api/os/stdout.html

But this code does not work, can’t find the output anywhere:

Var outgoing As TCPSocket = stdout

outgoing.write "Hello World"
outgoing.flush

you need to double click the app and select “execute in terminal” and the app needs to remain running (with a doevents loop) for it to print something.
The “print” function should be enough to output to stdout.

1 Like

For a Pi across the world you should SSH in and run by command line. As Derk mentioned, Print will go to stdout.

2 Likes

I’ve got a do events in the run even.

While StayAlive = True
  Doevents
Wend

What I have been using is TeamViewer to get onto the desktop, then click and run in terminal.

However the terminal window does not stay open.

This app has been daemonized too. Should I turn that off for this testing???

Thanks guys,
Tim

That’s probably why the desktop terminal is closing. You can set up systemd to run daemons if you need them.

1 Like

I have systemd already set up. So I guess I need to turn off the daemonization code, temporarily, in the app while trying to kill the bug?

If you’re using systemd to run the application you do not need App.Daemonize.

1 Like

I think that once daemonized, your app is detached from the tty (console) so prints vanish. Your app goes “background” but still belongs to your shell session. When you “click” the app to fire it, a shell session starts to contain it; once daemonized , its tty is detached and the app gets “mute”, and the shell “continues” (not waiting for stdin nor outputting to stdout). In such mode, continuing means run the next task, and such “next”, does not exist so such shell session ends, and ending such shell session means ending its current tasks, even a hidden one.

I wrote all that just reminding things without tests. But I think that maybe it’s what’s happening to you.

“Daemonize” in Xojo demands better docs.

There’s a difference firing
./myapp
and
./myapp &

The second one detaches your app from the shell session so it continues after the shell session end.

I wish I could do some tests, but have no time now. If someone could, I’m really curious about “daemonized” Xojo apps behavior.