bash scripting try something, but quit if it's taking too long
Chris F.A. Johnson
chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org
Tue Jun 22 19:37:47 UTC 2010
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
--
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
More information about the Legacy
mailing list