bash scripting try something, but quit if it's taking too long
Matt Price
moptop99-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed Jun 23 00:07:16 UTC 2010
On Tue, Jun 22, 2010 at 3:37 PM, Chris F.A. Johnson <chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org>wrote:
> On Tue, 22 Jun 2010, Matt Price wrote:
>
> > hi,
> >
> > quick scripting question. I have an irritating emacs bug, in which
> > emacs sometimes hangs when the network's disrupted. To deal with this
> > i have just send a command via emacsclient to the running server
> > before i suspend, which solves a solid 90% of my problems. but
> > sometimes emacs is already hung when i want to suspend! in that case,
> > my script hangs too and the suspend event never takes place, which is
> > almost always worse since it causes everything to lose data, not just
> > emacs. here's my tiny function:
> >
> > suspend_wl()
> > {
> > # Get WL to go offline
> > if [-f /tmp/emacs1000/server]
> > then
> > /usr/bin/emacsclient --socket-name /tmp/emacs1000/server
> > --eval "(wl-toggle-plugged 'off)"
> > fi
> > }
> > is there a "try" or similar command i can use around the emacsclient
> > command, to just continue if things are taking too long?
>
> wait=666 ## seconds before timing out
> suspend_wl & ## put function into the background
> sleep $wait ## wait
> kill $! ## kill last background process
>
> wouldn't that guarantee that you have to wait $wait seconds before suspend?
hmm.. is there no way to, say, test once a second to see whether the job has
finished?
anyway, thanks much for the help. best,
matt
> --
> Chris F.A. Johnson, <http://cfajohnson.com>
> Author:
> Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> --
> The Toronto Linux Users Group. Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/legacy/attachments/20100622/e4c5c835/attachment.html>
More information about the Legacy
mailing list