Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple bash script.

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Xraynorm
LXF regular


Joined: Tue Feb 07, 2006 9:36 pm
Posts: 122

PostPosted: Sun Jun 11, 2006 9:56 am    Post subject: Simple bash script. Reply with quote

Hello

I've built an wireless mp3 player out of an old compter using DSLiinux. When it boots it runs the command :-

xmms http://192.168.0.3:9000/stream.mp3

This connects to my server and plays my mp3s.

I would like to write a script that re executes the above line if it fails to connect.

This will enable me to turn off the main sever at night, and when I turn it back on the media player should reconnect automatically.

Any help would be greatfully received
Back to top
View user's profile Send private message
jmeads



Joined: Wed Nov 30, 2005 12:21 pm
Posts: 1

PostPosted: Sun Jun 11, 2006 10:47 am    Post subject: RE: Simple bash script. Reply with quote

you just need to wrap it in a while loop, something like

while 1
command here
end

ugly, but it should do the trick, see man bash for more info
Back to top
View user's profile Send private message
Steogede
LXF regular


Joined: Thu May 04, 2006 6:39 pm
Posts: 146

PostPosted: Sun Jun 11, 2006 1:43 pm    Post subject: Re: RE: Simple bash script. Reply with quote

jmeads wrote:
you just need to wrap it in a while loop, something like

while 1
command here
end

ugly, but it should do the trick, see man bash for more info


You probably want to don't want it to continually try to connect. Shove a sleep command in there to give it a breather. e.g.

while true; do
command here;
sleep 2m;
done;

However that probably isn't what you want. Re-executing 'xmms http://192.168.0.3:9000/stream.mp3' ever time it fails to connect will leave you with lots of copies of xmms running. When XMMS fails to connect, it doesn't shut down automatically. Also because XMMS doesn't shutdown when it loses/fails to get a connection, the above would only run the command once; until you manually closed xmms.

It seems from searching the net, it seems the best option is probably to run a stream server on the local machine. This server would relay the other server when it gets a connection and play a local file when it can't get a connection. Try searching for stream relay.

One more thing, if you are turning the server off at night, why would you want to keep the client on?

You may also want to see if you can find a command line player that will exit if it loses/fails to get a connection - mpg321 might be upto the job.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
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
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast