PID length


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PID length
# 1  
Old 12-20-2007
PID length

Does somebody know how many characters can have a PID as maximum?

I'm trying to get the PID of another process running in the same machine. I'm doing this:

Code:
ps -ef | grep "bin/Alime" | grep -v grep  | cut -c10-16

but I don't know if I 'll have enough with six chars. Which is the max value that it can take?

thanks in advance
# 2  
Old 12-20-2007
that depends on the maximum number allowed for a PID and it varies from system to system
# 3  
Old 12-20-2007
I'm looking for a PIDMAX or something like this, but I can't find anything. This is my system:
Code:
ASASTR:include> uname -a
OSF1 CLHASASTR V5.1 2650 alpha

Thanks again
# 4  
Old 12-20-2007
cannot you just get the whole column instead of relying on character ranges?
something like:
Code:
ps -ef | grep '[b]in/Alime' | cut -d ' ' -f1

# 5  
Old 12-20-2007
yes, the whole column would be great. I have tried to get only the second column

Code:
 ps -ef | grep "bin/Alime" | grep -v grep  | cut -f 2

but it shows the whole line again. I don't know why, maybe the command is not correct.

thanks
# 6  
Old 12-20-2007
Code:
ps -ef | grep '[b]in/Alime' | cut -d ' ' -f 2

cut's field delimiter is 'tab' by default......
# 7  
Old 12-20-2007
these are my outputs:

Code:
ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep
clh      221867 217065  0.0 11:34:01 pts/4        0:00.08 /usr/local/clh/ALPHA/oasys/bin/AlimentaLookAhead

ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep  | cut -c10-16
221867

ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep  | cut -d ' ' -f1
clh

ASASTR:clh>  ps -ef | grep "bin/Alime" | grep -v grep  | cut -d ' ' -f2

ASASTR:clh>  ps -ef | grep "bin/Alime" | grep -v grep  | cut -f2
clh      221867 217065  0.0 11:34:01 pts/4        0:00.08 /usr/local/clh/ALPHA/oasys/bin/AlimentaLookAhead

asking for the first column (-f1) i get the username, but asking for the second (-f2) i get the whole line.
Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

2. Shell Programming and Scripting

changing a variable length text to a fixed length

Hi, Can anyone help with a effective solution ? I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces. The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Discussion started by: dc18
7 Replies

3. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

4. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 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. 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

7. UNIX for Dummies Questions & Answers

Sed working on lines of small length and not large length

Hi , I have a peculiar case, where my sed command is working on a file which contains lines of small length. sed "s/XYZ:1/XYZ:3/g" abc.txt > xyz.txt when abc.txt contains lines of small length(currently around 80 chars) , this sed command is working fine. when abc.txt contains lines of... (3 Replies)
Discussion started by: thanuman
3 Replies

8. 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

9. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies
Login or Register to Ask a Question