|
|
Keep track of stopped processes via shell variables
To make this more general you can use the following commands to find the process id of a program
i.e. to find the Process Id of the Running Terminal.app you could use:
So to make your WORD variable up to date you could use,
in csh:
or in bash:
These variables can then be put in your .cshrc or .bashrc scripts so they're always available and always point to the correct process id.
Keep track of stopped processes via shell variables
To shorten your shell commands, either use brackets e.g.
ps -ax | grep '[k]ext' | awk '{print $1}' or, in sh/ksh/bash etc. it's easier to set and shift (positionals) ... but there is -- killall [-d | -v] [-h | -?] [-help] [-l] [-m] [-s] [-u user] [-t tty] [-c procname] [-SIGNAL] [procname ...] Also, if you started any commands from this shell (term), can just jobs -l then kill %1 bg %2 etc. Larry
Keep track of stopped processes via shell variables
Also, in a shell wrapper the pid of a launched (bg) command is available -- (csh)
some_command & ; set pid = ${!} kill ${pid} (sh) pid=${!} Larry.
Keep track of stopped processes via shell variables
Oh yeah, to make those greps correct (in case there are multiple binaries running with similar names), need to --
ps -ax | grep '[k]ext' | head -1 | awk '{print $1}' i.e. use head or tail to stuff just the first one into your variable; Larry. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|