log file outputs with photon

Hello,

we are developing client/server communication applications using an own
middleware (central object server). We like to realize the clients and
servers as flexible and user configurable photon windows while the
middleware runs in the background. Now we are looking for possibilities to
log the outputs of the middleware while the clients and servers are
communication.

Does anybody know how to log the screen outputs of an executable file into a
photon window? Which steps are to make in order to connect the executable
application and the photon application directly?

I hope to have not confused you while trying to explain the problem.

Thank you.

Nnamdi

ed1k wrote:

In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…

Hello,

we are developing client/server communication applications using an own
middleware (central object server). We like to realize the clients and
servers as flexible and user configurable photon windows while the
middleware runs in the background. Now we are looking for possibilities to
log the outputs of the middleware while the clients and servers are
communication.

Does anybody know how to log the screen outputs of an executable file into a
photon window? Which steps are to make in order to connect the executable
application and the photon application directly?

I hope to have not confused you while trying to explain the problem.


Hello,
I’m confused a little bit. I’m not GUI guy, but…
Can you launch Photon terminal ‘pterm’? Can you launch your executable from command line in that
pterm’s window? Then you can read all printf()s of that executable in pterm. What did I
missunderstand?

I can launch my execuable in pterm. That#s ok.
I also see the printf-outputs.
How can I put them to text widget in photon application builder (PhAB)?


Tobi.
(I’m concerned with this problem as well as Nnamdi)

In article <b6aage$j5p$1@inn.qnx.com>, nnamdi.kohn@tu-bs.de says…

Hello,

we are developing client/server communication applications using an own
middleware (central object server). We like to realize the clients and
servers as flexible and user configurable photon windows while the
middleware runs in the background. Now we are looking for possibilities to
log the outputs of the middleware while the clients and servers are
communication.

Does anybody know how to log the screen outputs of an executable file into a
photon window? Which steps are to make in order to connect the executable
application and the photon application directly?

I hope to have not confused you while trying to explain the problem.

Hello,
I’m confused a little bit. I’m not GUI guy, but…
Can you launch Photon terminal ‘pterm’? Can you launch your executable from command line in that
pterm’s window? Then you can read all printf()s of that executable in pterm. What did I
missunderstand?

Thank you.
Eduard.

Thank you.

Nnamdi

Tobias Moeglich <Tobias.Moeglich@web.de> wrote:

ed1k wrote:
In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…
[snip]
Tobi.
(I’m concerned with this problem as well as Nnamdi)

This is not an easy task, if I understand what you are asking.

First, you want the output, from one application, that is printed
to stdio, which is displayed by the shell run by pterm (another application),
to be displayed by a text widget in another application. Is this
correct?

If so, here are a few ideas:

  1. Redirect the output of the printfs to a file. Have the application
    with the text widget read from the file.

  2. Rewrite the application that does the printf, to use a cover
    function, for example, my_printf. When defining my_printf,
    on QNX6, you can have it send a message through IPC to
    the application with the text widget, and with other platforms,
    you would call printf.

Regards.

Derek Leach <dleach@node318.ott.qnx.com> wrote:

Tobias Moeglich <> Tobias.Moeglich@web.de> > wrote:
ed1k wrote:
In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…
[snip]
Tobi.
(I’m concerned with this problem as well as Nnamdi)

I have not tried this so I don’t know if it will do what you want.
But look at PtTerminal & PtTty widgets. See if you can use one of
them and then re-direct your programs stdout to the file descriptor
associated with this widget.

Bill Caroselli <qtps@earthlink.net> wrote:

Derek Leach <> dleach@node318.ott.qnx.com> > wrote:
Tobias Moeglich <> Tobias.Moeglich@web.de> > wrote:
ed1k wrote:
In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…
[snip]
Tobi.
(I’m concerned with this problem as well as Nnamdi)

I have not tried this so I don’t know if it will do what you want.
But look at PtTerminal & PtTty widgets. See if you can use one of
them and then re-direct your programs stdout to the file descriptor
associated with this widget.

I just re-read your original post. What you want is for an application
to display log information from a server process it is connected to?

This is a very common feature. I would just add a new api call to the
server to get this log information and display it in whatever form, and
whenever, it makes sense to do so.

If you don’t have access to the server (someone else wrote it?) then
just log the output from the server to a file, i.e.
my_server > log.file 2>&1
or
my_server | tee log.file 2>&1
This second example wil write the data to a log file and display it
on the console where it is running.

Then just periodicly try to read past the old EOF in the log file and
display any new data that is found.

Derek Leach <dleach@node318.ott.qnx.com> wrote:

Tobias Moeglich <> Tobias.Moeglich@web.de> > wrote:
ed1k wrote:
In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…
[snip]
Tobi.
(I’m concerned with this problem as well as Nnamdi)

This is not an easy task, if I understand what you are asking.

First, you want the output, from one application, that is printed
to stdio, which is displayed by the shell run by pterm (another application),
to be displayed by a text widget in another application. Is this
correct?

If so, here are a few ideas:

  1. Redirect the output of the printfs to a file. Have the application
    with the text widget read from the file.

  2. Rewrite the application that does the printf, to use a cover
    function, for example, my_printf. When defining my_printf,
    on QNX6, you can have it send a message through IPC to
    the application with the text widget, and with other platforms,
    you would call printf.

Use a pipe between the application you run and your GUI – i.e.
popen() your application or something similar.

Use a pseudo-tty between the application making the output and your
GUI application. (In fact, that is what pterm is – an application
that runs other applications on a pseudo-tty and turns their output
into Photon draws.)

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Bill Caroselli wrote:

Derek Leach <> dleach@node318.ott.qnx.com> > wrote:

Tobias Moeglich <> Tobias.Moeglich@web.de> > wrote:

ed1k wrote:

In article <b6aage$j5p$> 1@inn.qnx.com> >, > nnamdi.kohn@tu-bs.de > says…

[snip]

Tobi.
(I’m concerned with this problem as well as Nnamdi)


I have not tried this so I don’t know if it will do what you want.
But look at PtTerminal & PtTty widgets. See if you can use one of
them and then re-direct your programs stdout to the file descriptor
associated with this widget.

That works fine. Thanks for Your advice. In the mean time I found out
myself. I toke an example code fro the help (can be seen below).


One more questions:
Is there a possibility to start a fixed application from this window?
I don’t want to always type the path and the executable file.
I suppose there must be a solution for this.

I suppose: “Pt_ARG_TTY_CMD” or “Pt_ARG_TTY_ARGV” or “Pt_ARG_TTY_PATH”
has to do with it.

Regards Tobias.






/* Open a pseudo tty – NULL is a shortcut for “/dev”;

  • the widget will add something like “ttyp3” to it
    */
    PtSetArg( &arg, Pt_ARG_TTY_PSEUDO, NULL, 0 );
    PtSetResources( ABW_observ_Tty, 1, &arg );

PtSetArg( &arg, Pt_ARG_TTY_SFD, 0, 0 );
PtGetResources( ABW_observ_Tty, 1, &arg );

// Run a program on the pseudo tty. NULL is more or less a shortcut for
// “char *argv[] = { “/bin/sh”, NULL };” ,except it runs your shell
// rather than always /bin/sh.
PtSetArg( &arg, Pt_ARG_TTY_ARGV, NULL, 0 );
PtSetResources( ABW_observ_Tty, 1, &arg );

PtSetArg( &arg, Pt_ARG_TTY_PID, NULL, 0 );
PtGetResources( ABW_observ_Tty, 1, &arg );