Register
It is currently Tue Jul 29, 2014 6:44 am

command started execution


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Thu May 27, 2010 11:39 am   

Joined: Thu May 27, 2010 11:16 am
Posts: 1
hi

When I execute a command in the shell and that command takes a long time, I want bash to make a sound to warn me when it finishes.

Thiss would be implemented in PROMPT_COMMAND but I need to know the time the command started execution! any idea on how to implement this in bash?

daniel


Top
 Profile  
 PostPosted: Thu May 27, 2010 4:34 pm   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Before starting the command, just store
Code:
$(date +%s)
into a variable. When the command finishes, store the same into a second variable and subtract the variables. If the result is bigger than "short time", ring the bell, for example by
Code:
echo -n $'\a' >&2


Top
 Profile  
 PostPosted: Fri May 28, 2010 3:17 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Code:
date ; time mycommand ; echo '^G'


date gives you the start time. time gives you the execution time and the echo rings the bell.
Note that ringing the bell in this fashion may well not work on modern desktops unless your terminal is configured to do so.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP