Ok in rxvt but not in script

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#16 Post by big_bass »

Hey Gilbert

I played with grep and ps looking for a way to monitor services
for a little script I wrote to monitor cups
and I found another way of going at this


I tried to compile PSG but it failed but I liked the simple idea of it

so I found an alias instead that simulates it

Code: Select all

 alias psg='ps auxw | grep -v "grep -i" | grep -i --color'

then you just type

Code: Select all

psg cupsd
root 4561 0.0 0.1 4500 1584 ? Ss 19:07 0:00 /usr/sbin/cups



--------------------------------------


so I guess if wget was running

Code: Select all

psg wget 

psg wget
root 13181 0.5 0.1 3276 1336 pts/2 S+ 20:27 0:00 wget http://puppy2.org/slaxer/bluefish-1.0.7-i486-slxr.pet
#


add the filtering formatting you prefer
[/code]
nice and easy


Joe

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#17 Post by mikeb »

Hmm just thought of another approach to tracking and killing multiple spawned processes

Code: Select all

#make unique link to application
UNIQUE_ID="random string"
ln -s `which (binary)` /tmp/thing$UNIQUE_ID

#to run
/tmp/thing$UNIQUE_ID

#to monitor
[ `pidof thing$UNIQUE_ID` ]&& echo "It is still running"

#to kill....
kill `pidof thing$UNIQUE_ID`
rm /tmp/thing$UNIQUE_ID`

#or simply
killall thing$UNIQUE_ID
clean and simple, at least visually...probably a purists nightmare

mike

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#18 Post by mikeb »

Hey now here a kludge...rearranging only worked until there were spaces in the name.....I can tidy this up but would use the same method. I suspect the difference is to do with how multiple lines are handled in the terminal as apposed to a script

Code: Select all

function _status (){
	#stupid but what works in terminal will not work here so heres a bodge....
	ps | grep 'wget -c' | grep -v grep | sed 's%.*/\(.*\)-o.*%\1%' > /tmp/tart.status1
	ps | grep 'cclive -c' | grep -v grep | sed 's%.*/\(.*\)http.*%\1%' >> /tmp/tart.status1
	echo -e "\c" > /tmp/tart.status
	while read I ;do
	echo ${I##*/} >> /tmp/tart.status
	done < /tmp/tart.status1
}
I'm just assuming the first part of sed does not work reliably....all I wanted was to preserve the users readable name choice :lol:

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#19 Post by sunburnt »

This sounds just like the script problem amigo and I were struggling with...

Bash interprets the arguments instead of passing them as literals.
There seems to be no way around this except to do it differently...

Post Reply