Steve Bibayoff wrote:

Hello,

On 3/7/07, Ralph Shumaker <[EMAIL PROTECTED]> wrote:

$ cat ~/unlock-mozilla
#!/bin/bash
cd ~
echo \#!/bin/bash > ~/remove-mozilla-lock-file
ps -u $USER | grep mozilla-bin | sed -e 's/^\s*\([0-9]*\)[^!]*/kill -9 \1/' >> ~/remove-mozilla-lock-file du -a | grep \./\.mozilla/.*/lock | sed -e 's/^[0-9]*\s*\.\//rm ~\//' >> ~/remove-mozilla-lock-file
chmod 700 ~/remove-mozilla-lock-file
cat ~/remove-mozilla-lock-file
~/remove-mozilla-lock-file
rm ~/remove-mozilla-lock-file
$

I made it so it would kill -9 any Mozilla programs currently running
under $USER, just in case she somehow switched to a different
workspace.  She's fairly limited in knowledge of computers but *more*
limited in patience.  She just needs it to work and have quick simple
solutions for when it doesn't.  (I think I might reduce the number of
her workspaces down to one, juuuust to be on the safe side.)


You might wqnt to take a look at:
man pkill
man pgrep


hth,


It always helps to become aware of other commands, especially when they might be able to shave off some complexity.

I guess this:

ps -u $USER | grep mozilla-bin | sed -e 's/^\s*\([0-9]*\)[^!]*/kill -9 \1/' >> ~/remove-mozilla-lock-file

would simplify to:

pgrep -u $USER mozilla-bin | sed -e 's/^/kill -9 /' >> ~/remove-mozilla-lock-file


That certainly is easier on the eyes, and much easier to read.

I realize that pkill would allow me to just kill it directly.

pkill -u $USER mozilla-bin


But I kinda like the idea of having a script created that shows exactly what was done.

Maybe:

echo pkill -u $USER mozilla-bin >> ~/remove-mozilla-lock-file


(In the version I posted, (after a cat to the terminal (if run from one)) it ends by erasing that script file, but I could easily #remark that out. And pgrep/pkill won't help me with a leftover lock file, so I still have to create a script to do that..., unless there is another way. (And knowing *nix, there probably is. (Anyone?)))


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to