| Title: | Welcome to Korn_Shell_Programming | 
| Moderator: | PLUGH::needle | 
| Created: | Tue Jun 25 1991 | 
| Last Modified: | Fri May 30 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 118 | 
| Total number of notes: | 426 | 
    
    > ps -o ucomm,pmem,nswap,inblock,oublock,pcpu
    COMMAND          %MEM NSWAP INBLK OUBLK %CPU
    csh               0.3     0    14     8  0.0
    netscape          9.6     0  8143  6848  0.0
                       ^      ^    ^     ^    ^
                       |      |    |     |    |
    how do you write ksh script to read the above values and assign them
    to variables and then use them for calculation ?
    
    -Man
    
| T.R | Title | User | Personal Name | Date | Lines | 
|---|---|---|---|---|---|
| 118.1 | SPECXN::DERAMO | Dan D'Eramo | Wed May 14 1997 11:13 | 22 | |
| 
        Maybe this small example will get you started...
        
        Dan
        
        
#!/usr/bin/ksh
ps -o ucomm,pmem,nswap,inblock,oublock,pcpu |&
n=0
while read -p command mem nswap inblk oublk cpu
do
    n=$((n+1))
    echo Line $n
    printf '    command = %s\n' $command
    printf '    mem     = %s\n' $mem
    printf '    nswap   = %s\n' $nswap
    printf '    inblk   = %s\n' $inblk
    printf '    oublk   = %s\n' $oublk
    printf '    cpu     = %s\n' $cpu
done
 | |||||
| 118.2 | NQOS01::lexser22.lex.dec.com::Ginger | Ron Ginger, Unix Consultant | Fri May 30 1997 14:44 | 1 | |
| use perl | |||||