Hi,
I am very new to scripting, but I am very keen to learn.
Right now, I have an input file containing the output of ps -emo THREAD (in AIX) where the lines look something like this:
I am trying to format this to an output file so that all threads (TID) have the process id they belong to in the 2nd field.
My idea is:
1) If $2 is not '-', then
a)send the whole line to the output file and
b)store the value of $2 in a variable $mt that can be used when the next line is read
2) Read the next line
a)if $2 is not '-', then send the whole line to the output file and
b)if $2 is '-', then replace this with the value of $mt taken from the previous line and write to the output file
c)in case of b) reconfirm the same value for $mt, as there may be more threads to the same pid to read.
This is what I have done:
If I comment out the else line, then it prints all the lines where $2 is not - to the output file, but when I run it with the else condition I get:
I can´t find any examples of what I am trying to do, although I imagine it´s a simple mistake to spot for those of you that use awk regularly..
Thanks in advance!
Teresa.
Last edited by pludi; 02-05-2010 at 07:43 AM..
Reason: code tags, please...
I definitely have to work on shortening my script. Thanks for the tip, Scrutinizer! )
However, either way I run it, it doesn´t do what I need it to do. Back to the file:
I have a script that will be run beforehand to identify "problematic" transactions (definition of "problematic" is irrelevant for now). So, I will have a transaction id (TID) that I will use to grep this file with all master processes and their transactions, to find the master process the problematic transaction belongs to. Lets suppose the bad TID is 86067. The 2nd field in the file would identify the PID, but notice it has a '-'. The PID for this thread would be the PID number in the above line. Sometimes there´ll be many transactions (pid='-') for a master process.
Unless we can read "upwards" to the nearest pid number, I would like to format the file with all the processes, so that all transactions "inherit" the pid number in the second field instead of having a '-'.
Hope this is a little clearer. If you have a better idea for doing this rather than formating the file so I can grep by the transation id and then read the 2nd field, I am all ears! )
Teresa.
Last edited by pludi; 02-05-2010 at 10:27 AM..
Reason: code tags, please...
Wow! Thanks, Scrutinizer, that worked. It has taken me a while to incorporate it into my script where it had to read the TID value from a file generated in a previous function. I have so much to learn... )
Hello,
In a loop I am using below command for every database
crsctl status res | grep -E "ora\.$DATABASE\.(.+)\.svc" and below is one of the sample output
NAME=ora.sgraphut.sgraphutxdb.svc
Now I want to extract just service name out of this string (that is sgraphutxdb) please help me how... (1 Reply)
Hi,
I posted a request for sever OS types earlier, but got no response. In an attempt to at least have a starting point, I think scaling it to one OS is preferred. Once I see the gist of it I can modify to account for different cases.
I need a script that will go and check to see if an LDAP... (2 Replies)
Hello gurus
I am looking for a script :
We need to generate a file list created by user id on a AIX box.
Criteria 1: other than userid : dwimpid & aiadmin
Criteria 2: Files older than 2 months ( it can be any user id ).
File Path to Look: /project and /project1
Thx
silu (7 Replies)
I need to write the script for the below constraints. Need your help urgently
The PATH environment variable must conform to the following:
• World-writeable directories (/tmp, /var/tmp etc) must not be placed in the PATH variable.
• System directories must always be placed before local... (1 Reply)
I am looking for a script which does the following
Script will run daily.
1.It will get snapshot off all filesystems including nfs mounts, automounts and clearcase mounts.
2.Then it will compare new snapshot with the snapshot created in the previous run.
3.If filesystem exists in... (20 Replies)
Hi,
I am writing a korn shell script in AIX. I want to pass the date as a parameter to script and inside it should convert the format to +%a" "%h" "%d" "%Y.
For e.g., a parameter passed as "20100301" should be converted to "Mon Mar 01 2010". I can easily do this with AIX "date" option for... (2 Replies)
ok... want to start off by saying i am sorry for the ignorance... still trying to figure out the diffs between solaris and aix... and i think that is where i am running into problems... :o
SITTIATION:
we are doing an implementation for Oracle's CC&B... we recently switched from... (1 Reply)
Hi All,
I need to script a routing changes on my aix servers. I can't use smitty, very slow.
I need to delete the static routing and add a new one. I also need to change default routing.
I know using route add and route delete but I think I remember that this is not enough that's why I... (2 Replies)
can someone pls help me with the script for a files coming from one system to a particular directory and i want to write a script to move those files to another directory on different system by renaming the files...
pls someone help me on this...
thanking in anticipation.... (1 Reply)