Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 20 Oct 2014, 19:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Ok in rxvt but not in script
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Author Message
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Thu 07 Jan 2010, 22:30    Post subject:  

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:
 alias psg='ps auxw | grep -v "grep -i" | grep -i --color'



then you just type
Code:
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:

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

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8342

PostPosted: Mon 18 Jan 2010, 22:25    Post subject:  

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

#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
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8342

PostPosted: Wed 27 Jan 2010, 06:24    Post subject:  

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:
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 Laughing

mike
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Sat 06 Feb 2010, 03:15    Post subject:  

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...
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0684s ][ Queries: 11 (0.0235s) ][ GZIP on ]