awk PID


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk PID
# 1  
Old 03-14-2011
awk PID

Can any one tell me the meaning of the following.. I am still learnig unix
Thanks in advance

1)
Code:
 if ($1 == "tommCumulative)") 
   { 
      if (PID == 7)
      {
         printf(",CUM_READ = to_number(%d,'XXXXXXXXXX')\n",$2 * SC)
      }
      else
      {
         printf (",CUM_READ = %d\n",$2 * SC) 
      }
   }

2)
Code:
Protocol_id=`grep txOnlyProtocolID $remoteTmpOndDir/ond.tmp.$1 | awk '{print $6}'`

3)
Code:
nawk -f $BIN_DIR/odr_crupdt.awk SC=$SCALING_CONST INT=$DEMAND_INTRVL PID=$Protocol_id $remoteTmpOndDir/ond.info.$1 >> updt_ond_$1.sql


Last edited by joeyg; 03-14-2011 at 03:56 PM.. Reason: Please use CodeTags, especially to maintain indents and formatting
# 2  
Old 03-14-2011
We need some context. What are these from?
# 3  
Old 03-14-2011
there is a awk script called "odr_crupdt.awk" in which i have the following command.
1) if ($1 == "tommCumulative)")
{
if (PID == 7)
{
printf(",CUM_READ = to_number(%d,'XXXXXXXXXX')\n",$2 * SC)
}
else
{
printf (",CUM_READ = %d\n",$2 * SC)
}
}


that is beingcalled under get_odr.sh in the following way. On line 3 you see "odr_crupdt.awk" being called. and I want to know meaning of line 2 also

line 2) Protocol_id=`grep txOnlyProtocolID $remoteTmpOndDir/ond.tmp.$1 | awk '{print $6}'`
line 3) nawk -f $BIN_DIR/odr_crupdt.awk SC=$SCALING_CONST INT=$DEMAND_INTRVL PID=$Protocol_id $remoteTmpOndDir/ond.info.$1 >> updt_ond_$1.sql
# 4  
Old 03-14-2011
You've still given no context, so I can't explain why they're doing what they do.

I don't know what that "PID" variable is. It must have been set somewhere else. I don't know what SC is either. I also don't know why they're checking for 7, or what tommcumulative is.

All I can tell you is, it's doing this: "if the first token is tommcumulative, and the PID is 7, print the string ",CUM_READ = to_number(%d,'XXXXXXXXXX')\n", substituting the second token times SC for %d. Otherwise, print ",CUM_READ = %d\n", substituting the second token times SC for %d. And if the first token isn't tommcumulative, don't do anything inside this block at all."

In the second line, they're matching lines containing the text "txOnlyProtocolID" from the file $remoteTmpOnDir/ond.tmp.$1. I don't know what $remoteTmpOnDir is, that must have been set earlier. I don't know what $1 is, that's the first parameter of the script. And they feed the output through awk, printing only the sixth field, and shoehorn the whole mess into the Protocol_id variable.
Protocol_id=`grep txOnlyProtocolID $remoteTmpOndDir/ond.tmp.$1 | awk '{print $6}'`

For the third one, they're running the awk script $BIN_DIR/odr_crupdt.awk. I don't know what BIN_DIR is, that's something that's set earlier. They're presetting a whole bunch of variables in there, some of which correspond to variables used earlier, like SC=$SCALING_CONST and INT=$DEMAND_INTRVL, and of course that PID variable that got grepped out of that file, whatever it is. What they are and why I couldn't say. What $1 is I also couldn't say.
# 5  
Old 03-14-2011
First Let me thank you very much for your reply, That pretty much made me understood what it is doing and why it is doing. There is whole bunch of unix shell script, that is the reason why I could not attach all that. like you mentioned those dir are alredy set up..

Regards
RP
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

fuser - how to select the given PID? (awk/sed)

Hello, I'm trying to select, or well put the PID that is given by fuser to a var.. It has a wierd format and I somehow can't get it working, any awk/sed experts about? PID=`fuser $file | awk/sed....?` if ; then kill $PID fi Greetings and thanks for all your awesome help in advance! (4 Replies)
Discussion started by: TehOne
4 Replies

2. UNIX for Dummies Questions & Answers

PID value

name the process wit PID value 0? swapper or scheduler or both.... (3 Replies)
Discussion started by: karthi_g
3 Replies

3. Shell Programming and Scripting

Output of ps + awk in a variable to get PID

Hi All, I am getting the PID of a process using its name using the following command in a script mypid=`ps aux | awk '/test5/ && !/awk/ { print $2 }'` echo PID is $mypid The problem is the PID is not getting printed. But when i run the command directly in shell, the PID got printed. ... (2 Replies)
Discussion started by: amio
2 Replies

4. UNIX for Dummies Questions & Answers

Another PID ?

I have searched to find an anwer to no avail, I hope you can help me. I have a.ksh that many people call and a.ksh calls b.ksh b.ksh is also invoked stand-alone by many people as well In b.ksh I want to do something different if it was not involked by a.ksh. How can I do this? (7 Replies)
Discussion started by: CAGIRL
7 Replies

5. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

6. Shell Programming and Scripting

Pid

How can I put the process id of ,for example, the following script to the pid file? Maybe $$ must be defined in some place? daemon(){ while true; do if then echo "`date +"%H:%M:%S"`" >> $FILE ... (4 Replies)
Discussion started by: mirusnet
4 Replies

7. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

8. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

9. Shell Programming and Scripting

how to get PID only

The below command returns full line.How can i get only PID from this line ie 15794 from the below example (FI NY) nbswpsa52.ny.ficc.gs.com~ ->ps -ef | grep keepalive | grep -v keepaliveStub | grep -v swapback | grep -v grep ficctprd 15794 1 0 13:12:58 ? 0:01 keepalive (3 Replies)
Discussion started by: kotasateesh
3 Replies

10. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies
Login or Register to Ask a Question