1831482 Members
3364 Online
110025 Solutions
New Discussion

How to log hpterm window

 
Henry Chua
Super Advisor

How to log hpterm window

Hi Guys,

I have this program which spawns a seperate hpterm window when I run. I wished to capture (as a log)whatever that is shown in this window..but it closes after the program completes running. the process that is run is shown as "hpterm -T Deskew -n Deskew -sb -geometry 80x20+200+387 -lf /" ==> when run "ps -ef". Do you guys know how I can solve this problem?

Best regards
Henry Chua
Have a nice long holiday!!!
10 REPLIES 10
Pete Randall
Outstanding Contributor

Re: How to log hpterm window

Henry,

This is an admitted guess, but I wonder if you can pop your hpterm window with the "-e script " argument (see man script).


Pete

Pete
Greg OBarr
Regular Advisor

Re: How to log hpterm window

I assume this is a binary rather than a script that is spawning the hpterm window. Have you tried using this:

# ./program_name > /tmp/logfile.log 2>&1

This should redirect all the output, including errors displayed, to the logfile.

-greg
Biswajit Tripathy
Honored Contributor

Re: How to log hpterm window

Try:

# hpterm -e script /tmp/logfile.$$

This should open a logfile with a different name
everytime ($$ would be the process ID of the hpterm
that started the script).

Since you are calling this from a script, you could
generate more detail about the user who is executing
"hpterm" and add that at the top of the logfile.

- Biswajit
:-)
Henry Chua
Super Advisor

Re: How to log hpterm window

Hi Guys,

Thank u for your inputs. If I were to know the PID of the spawned hpterm. Can I not used a certain script of commands to capture whatever output on it?
Possible?

Best regards
Henry
Biswajit Tripathy
Honored Contributor

Re: How to log hpterm window

Could you rephrase that question? Where do you
want the PID of the spawned hpterm?

If you want it in a script running in the spawned
hpterm, then use
# echo $$

If you want it in the script in the parent shell that's
spawning the hpterm, then you need to follow
these steps (I'm not logged into a hp-ux
system now, so I can't give the exact script):

1) Get current shell pid (use "echo $$"), then open
the hpterm (with script command).
2) Run "ps -ef", grep the output for "hpterm", grep
for parent pid (found in step 1) in the Parent PID
field (use awk to print PID and PPID field only).
3) Get the PID of hpterm.

- Biswajit
:-)
Henry Chua
Super Advisor

Re: How to log hpterm window

Hi Biswajit,

Thank u for your reponse..
What I really like to know is how can I capture whatever output that is directed to this spawned hpterm.

U see, when I start running a script, it will open a new hpterm and redirect all the output to it.. once the script finishes, the hpterm window closes too.

I have tried directing the out put by doing
./program_script >logfile 2>&1 but it gives me an error "ambiguous output redirect". So I was just thinkin if I can know the PID of this spawned hpterm; which as u know can be acquire using ps -ef, can I use any command with the PID to direct the output of the spawned hpterm to a logfile.

Thanks again for your support =)

Best regards
Henry

Noel Miranda
Frequent Advisor

Re: How to log hpterm window

Hi Henry,

Try this out.

sh -x | tee

Biswajit Tripathy
Honored Contributor

Re: How to log hpterm window

Henry Chua wrote:
> U see, when I start running a script, it will open
> a new hpterm and redirect all the output to it..
> once the script finishes, the hpterm window
> closes too.

Correct. But when you open the hpterm with the
following command,

# hpterm -e script /tmp/logfile

the output (i.e whatever is printed in the new
hpterm) is also stored in /tmp/logfile. (which is what
I understand you want to do). See the manpages
for "script".

# man script

- Biswajit
:-)
Christian Deutsch_1
Esteemed Contributor

Re: How to log hpterm window

Dear Henry,

Maybe this can help too:

from any shell you can start the "script" utility (man script) to save all shell inputs and outputs to a file. You could call script from .profile for instance. Script will start another shell on top of the currently running shell.

Kind regards, Christian
Yeshua loves you!
Bill Hassell
Honored Contributor

Re: How to log hpterm window

Actually, it is trivial to log everything in an hpterm window:

hpterm -l -lf /var/tmp/hpterm.log

The -lf sets the logfile name but the -l turns on the feature.


Bill Hassell, sysadmin