LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2006, 02:57 PM   #1
Ashrack
Member
 
Registered: Oct 2005
Distribution: Ubuntu - Edgy Eft
Posts: 173

Rep: Reputation: 30
Can anyone write me a super quick script?


Total N00B in programing. Only thing I know little about is the old MSDOS programing...
So I would be gratefull if someone could write me a script to do the following in Linux please.

I would like to have a script that would first check if BEEP MEDIA PLAYER is running and if it is it would lunch the following:
Code:
beep-media-player -s
but if BEEP MEDIA PLAYER isn't running than the script should just exit.
 
Old 03-02-2006, 04:48 PM   #2
Cottsay
Member
 
Registered: Feb 2004
Location: Chaska, MN
Distribution: Fedora
Posts: 195

Rep: Reputation: 31
simply use notepad and put the command in just like that and save it as a .BAT file (bat for batch) - whenever you run that file, it will perform that command.
 
Old 03-02-2006, 06:00 PM   #3
s9ghost
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
Code:
result=`ps -A | grep beep-media-player`
if [ "$result" == "" ]
then
exit
else
beep-media-player -s
fi
May not be the best, cleanest, or shortest code, but it should work. If beep-media-player isn't running the script will exit, if it is running it will execute beep-media-player -s.

If it doesn't work try running beep media player and typing ps -A and seeing what beep is called on the process list and matching it with the string after the grep call.
 
Old 03-03-2006, 12:26 AM   #4
Ashrack
Member
 
Registered: Oct 2005
Distribution: Ubuntu - Edgy Eft
Posts: 173

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Cottsay
simply use notepad and put the command in just like that and save it as a .BAT file (bat for batch) - whenever you run that file, it will perform that command.
But that wouldn't do what I want... And anyways am using LINUX
 
Old 03-03-2006, 12:27 AM   #5
Ashrack
Member
 
Registered: Oct 2005
Distribution: Ubuntu - Edgy Eft
Posts: 173

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by s9ghost
Code:
result=`ps -A | grep beep-media-player`
if [ "$result" == "" ]
then
exit
else
beep-media-player -s
fi
May not be the best, cleanest, or shortest code, but it should work. If beep-media-player isn't running the script will exit, if it is running it will execute beep-media-player -s.

If it doesn't work try running beep media player and typing ps -A and seeing what beep is called on the process list and matching it with the string after the grep call.
I believe this is exactly what I am looking 4. Can hardly wait to test it when I get home.
TANX
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nfs write == super slow; read == super fast - problem? BrianK Linux - Networking 4 08-23-2007 10:59 PM
audioconvert! the new super script to convert audio files! :) thetroublemaker Linux - Software 16 03-11-2007 06:14 AM
Need quick 1-line script help. mehesque Linux - Software 2 08-24-2005 02:18 PM
Write Driver for NIC?help me quick!!! nguyenhoangha Programming 3 02-15-2004 02:27 PM
Super quick question.... Daniel Linux - Newbie 12 07-30-2002 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration