Sign in to follow this  
Followers 0
kizzle

Basic scripting question

6 posts in this topic

I fall asleep better when I listen to music. Trouble is I hate waking up to it. I wrote a really simple script that kills xmms in 2 hours but it is very inflexible. Here is the script in it's current sad state, any help would be greatly appreciated in making it more usable.

#!/bin/bash

# I would like to have the script figure out the pid of xmms on it's own

# Xmms has several processes running at once, killing any one of them

# kills them all

echo Killing xmms pid 11470 in 2 hours

# It's optional but it should ask the user how long it should wait

sleep 7200

# Again it should be able to figure out the pid on it's own

kill 11470

# Rather than killing it, is there a way to simply tell xmms to stop playing?

0

Share this post


Link to post
Share on other sites

If you're going to sleep at roughly the same time every night, this should work-

#!/bin/bashkillall XMMS

Have cron run it at at the appropriate time.

But if sleepy time is going to be variable, something like this might work-

#!/bin/bashsleep $1killall XMMS

Name it whatever you like, but for the sake of demonstration I'll call it "XmmsGenocide".

It's usage would be: XmmsGenocide "sleep_time_in_seconds"

Hope this helps. If not, call me a faggot and I'll try to get it right next time.

0

Share this post


Link to post
Share on other sites

I've made the script much more usefull. Thanks for the help!

#!/bin/bash

echo Stopping current song xmms is playing in $1 minutes

sleep $1m

xmms -u #pauses the current song

echo Done

0

Share this post


Link to post
Share on other sites
Hope this helps. If not, call me a faggot and I'll try to get it right next time.

paracord you sexy bish.

0

Share this post


Link to post
Share on other sites

In case anyone wants to know how to do what he originally wanted I have a script that does just that

#!/bin/bashPID="`ps -aux | grep [s]ystemlog | awk '{print $2}'`"kill $PID

you can change it to grep whatever you want, the [] keeps grep from matching its own process, if more than one process matches the string it will kill them all. Also you could expand on it more taking command line arguments for what process to search for and kill and how long to wait.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0