Operating System - HP-UX
1753873 Members
7485 Online
108809 Solutions
New Discussion юеВ

Re: Korn scripting question

 
SOLVED
Go to solution
u856100
Frequent Advisor

Korn scripting question

Hi All,

I'm trying to run the following ....

$ script test.scr
$ ls -1 *.txt
$ exit
$ cat test.scr

... but inside a korn script. So something like :

#/usr/bin/ksh
script test.scr << EOF
ls -1 *.txt
exit
EOF
cat test.scr

This obviously will not work, but does anyone know how I can pass an exit statement to the script process in order for it to terminate?
The script is more complicated than the above (in case someone asks why I'm using the 'script' binary), but I cannot redirect the following to a file :

find /app/oracle/admin/udlgrid1/udump -name "*.trc" -mtime 2 -exec /usr/sbin/fuser {} \; | grep : | awk -F":" '{print $2;next}'

my attempt using :
find /app/oracle/admin/udlgrid1/udump -name "*.trc" -mtime 2 -exec /usr/sbin/fuser {} \; | grep : | awk -F":" '{print $2;next}' > tracefiles.txt

does not seem to work

any other options appreciated

thanks in advance
John
chicken or egg first?
7 REPLIES 7
Steven E. Protter
Exalted Contributor
Solution

Re: Korn scripting question

Shalom John,

I would suggest building a two script system with an exit at the end of the second script.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ralph Grothe
Honored Contributor

Re: Korn scripting question

If I remember correctly, if you only require the PIDs of "active" files then you need to redirect stderr of the HP-UX incarnation of the fuser command to /dev/null.
Try appending 2>/dev/null before piping into grep or awk.
I'm not quite sure if I got what your intentions are?
Madness, thy name is system administration
spex
Honored Contributor

Re: Korn scripting question

John,

I'm also not sure of your intentions. Oracle trace files are generated when a background process or user process encounters an exception. I don't see why any process would have a trace file open after it has been written to initially.

In any event, you may want to give 'lsof' a shot, although I personally find it very flaky under HP-UX.

By the way, the format of a background trace filename is:

sid_proc_ospid.trc

where
sid = Oracle instance name
proc = Oracle bg thread name
ospid = HP-UX pid

As you can see, the pid of the offending process is embedded in the filename. This is also true for user thread trace files, although the naming format is a bit different.

PCS
u856100
Frequent Advisor

Re: Korn scripting question

thanks people, appreciate the responses. We have some problems with oracle not releasing file handles on trace files (very strange). As a result our housekeeping scripts are creating a load of zombie processes that are still claiming space.

I'll go with the two script option

many thanks again
chicken or egg first?
rariasn
Honored Contributor

Re: Korn scripting question

Hi Joh,

Use the "exec" command rather "script"

Sample:

# begin script
exec > /tmp/sample.txt
find /app/oracle/admin/....
...
# end escript

rgs,


Peter Nikitka
Honored Contributor

Re: Korn scripting question

Hi,

if you want to have the stderr as well in the file - what I assume - modify the solution of rgs to:

exec >/tmp/listing 2>&1
commands...


mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Arturo Galbiati
Esteemed Contributor

Re: Korn scripting question

Hi,
you could use the '{}' way:

#/usr/bin/ksh
{
ls -1 *.txt
exit
} >test.src
cat test.scr

HTH,
Art