Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: timeout problem in ssh sessions



On 2008-02-15, 12:30, Bart Schaefer wrote:

> Some suggestions follow.
Coooool!  Thanks a lot.
I didn't realize I wasted so much CPU and lines of code.

> } ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd | /bin/grep -v "etime,bsdtime,cmd" | /bin/grep -iE "(^USER|$$)" | /bin/grep -v "grep -iE"
> 
> Why do you need ignore-case in that grep?
Just a copy&paste error :-(

I copied from a function in my .zsh/alias that I use regularily:

 alias psl='ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd --sort user,pid | /bin/grep -v "etime,bsdtime,cmd"'
 look () { psl | /bin/grep -iE "(^USER|$*)" | /bin/grep -v "grep -iE" }

There I am searching case-insensitively because I also like to search for
process names.

> Better still, since you're about to do the same ps|grep on the PPID:
> 
> ps="$(ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd)"
Wonderful!  To avoid that $ps contains the ps process itself I combined
your two suggestions:
 ps="$(/bin/grep -v 'etime,bsdtime,cmd' =(ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd))" 

Is that ok / efficient?

> } echo -n "Still open file descriptors: "
> } perl -e 'print join(" ", grep { -t $_ } 0..63)."\n"'
> } echo ""
> 
> That's only telling you which descriptors are still connected to the tty,
> not which ones are open, so you'll miss X connections and the like.
Oh, too bad.  Actually I _do_ want to see X connections and the like
Is there a way to achieve this?

> } if whence xsel > /dev/null 2>&1; then
> 
> No need for this test: If it's not in the ps output, you're not going to
> do anything with it, and if it is in the ps output, it must exist, right?
Right.  I wanted to avoid the extra "ps" on machines where xsel doesn't
exist.  But your version is a lot smarter.

Thank you again!
 Andy.

-- 
 "JAVA truly is the great equalizing software.
  It has reduced all computers to mediocrity and buggyness." -- NASA



Messages sorted by: Reverse Date, Date, Thread, Author