Sponsored Content
Full Discussion: Perl script countdown
Top Forums Shell Programming and Scripting Perl script countdown Post 302941827 by cmccabe on Tuesday 21st of April 2015 02:24:23 PM
Old 04-21-2015
Perl script countdown

In the below bash when the perl is it possible to hide the commands from running on screen and display a process countdown?

For example, on the cygwin screen now the user sees each process in the command running as running protocol refGene, running protocol popfreq_all, etc... Could a display with a countdown be used instead or maybe an hour glass displays until the entire process completes? Thank you Smilie.

Code:
annovar() {
    # combine id and position files
	cd 'C:\Users\cmccabe\Desktop\annovar'
	cp out_parse.txt "$(cat target.txt)"
	
	# run annotation
              $( perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f ")' < target.txt )
			  
     printf "The annotation is complete, would you like analyze additional target gene patients? Y/N "; read match_choice
	 case "$match_choice" in
        [yY]) id="${id}"; menu ;;
        [nN]) id="${id}"; remove ;;
		esac
}

Maybe:
Code:
 
countdown=operation # there are (6) after the -operation
while [[ ${countdown} -ge 0 ]]
do
        echo ${countdown}
        sleep 1
        countdown=$(( ${countdown} - 1 ))
done 
Time until Completion = "${countdown}"


Last edited by cmccabe; 04-21-2015 at 05:25 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

shell script - loop to countdown

I am taking a class in UNIX and have written a script that needs to countdown from a number that is read in from the keyboard to zero. If no number is given the start of the countdown should default to 10. I can't get this to do the default #! /bin/sh echo Enter a number here to countdown... (2 Replies)
Discussion started by: froggwife
2 Replies

2. Shell Programming and Scripting

Display runnning countdown in a bash script?

I am looking for a way to display on a single line, a running countdown for a given amount of time in a terminal using a bash script. I am looking for this to use as part of a larger bash script that captures Video. The script sets up a bunch of parameters for DVgrab, and one of the parameters... (11 Replies)
Discussion started by: Starcast
11 Replies

3. UNIX for Dummies Questions & Answers

countdown in unix?

is there a script to preform a countdown from 10 seconds to 0? (5 Replies)
Discussion started by: JamieMurry
5 Replies

4. Shell Programming and Scripting

countdown to christmas

was wondering if there was a script that would countdiwn the days until christmas (3 Replies)
Discussion started by: trob
3 Replies

5. Shell Programming and Scripting

Stop! (the countdown!) :-) shell script help

Hi guys, I've found two nifty little scripts on these forums one which detects if the F5 key has been pressed: #/bin/sh _key() { local kp ESC=$'\e' _KEY= read -d '' -sn1 _KEY case $_KEY in "$ESC") while read -d '' -sn1 -t1 kp do _KEY=$_KEY$kp ... (0 Replies)
Discussion started by: rich@ardz
0 Replies

6. Shell Programming and Scripting

Anyone know of any FUN countdown script

Hi all, Does anyone know of any FUN countdown script that I can use for my script? At the moment, am just using sleep 10 or more and then print stuff into the screen to allow more time for the user to decide whether they want to continue running the script or abort? Just thought of wanting... (3 Replies)
Discussion started by: newbie_01
3 Replies

7. Shell Programming and Scripting

Bash - countdown timer

Hello, I have another problem with my script - I would like to have a countdown timer visible on the screen, and at the same time, I want te be able to do something else. And when the time runs out, I need to know about that inside the script somehow and do some action. I guess that would require 2... (3 Replies)
Discussion started by: xqwzts
3 Replies

8. Ubuntu

Countdown timer with seconds

I would like this to work with seconds as well. #!/bin/bash # if ; then echo "Incorrect usage ! Example:" echo './CountDown.sh -d "Jun 10 2011 16:06"' echo 'or' echo './CountDown.sh -m 90' exit 1 fi now=`date +%s` if ; then until=`date -d... (7 Replies)
Discussion started by: drew77
7 Replies

9. UNIX for Beginners Questions & Answers

Banner Countdown Timer

Hello. I am pretty new to unix and shell scripting and I was wondering if there might be a way to banner a countdown timer inside a script. We currently have an existing script that does a 2 minute sleep but thought it might be fun to actually make it banner a countdown timer until it is finished.... (3 Replies)
Discussion started by: thumbelina
3 Replies
xscreensaver-command(1) 					XScreenSaver manual					   xscreensaver-command(1)

NAME
xscreensaver-command - control a running xscreensaver process SYNOPSIS
xscreensaver-command [-display host:display.screen] [-help | -demo | -prefs | -activate | -deactivate | -cycle | -next | -prev | -select n | -exit | -restart | -lock | -version | -time | -watch] DESCRIPTION
The xscreensaver-command program controls a running xscreensaver process by sending it client-messages. xscreensaver(1) has a client-server model: the xscreensaver process is a daemon that runs in the background; it is controlled by other foreground programs such as xscreensaver-command and xscreensaver-demo(1). This program, xscreensaver-command, is a command-line-oriented tool; the xscreensaver-demo(1). program is a graphical tool. OPTIONS
xscreensaver-command accepts the following command-line options: -help Prints a brief summary of command-line options. -demo This just launches the xscreensaver-demo(1) program, in which one can experiment with the various graphics hacks available, and edit parameters. -demo number When the -demo option is followed by an integer, it instructs the xscreensaver daemon to run that hack, and wait for the user to click the mouse before deactivating (i.e., mouse motion does not deactivate.) This is the mechanism by which xscreensaver-demo(1) communicates with the xscreensaver(1) daemon. (The first hack in the list is numbered 1, not 0.) -prefs Like the no-argument form of -demo, but brings up that program's Preferences panel by default. -activate Tell xscreensaver to turn on immediately (that is, blank the screen, as if the user had been idle for long enough.) The screen- saver will deactivate as soon as there is any user activity, as usual. It is useful to run this from a menu; you may wish to run it as sleep 5 ; xscreensaver-command -activate to be sure that you have time to take your hand off the mouse before the screensaver comes on. (Because if you jiggle the mouse, xscreensaver will notice, and deactivate.) -deactivate This tells xscreensaver to pretend that there has just been user activity. This means that if the screensaver is active (the screen is blanked), then this command will cause the screen to un-blank as if there had been keyboard or mouse activity. If the screen is locked, then the password dialog will pop up first, as usual. If the screen is not blanked, then this simulated user activity will re-start the countdown (so, issuing the -deactivate command periodically is one way to prevent the screen from blank- ing.) -cycle If the screensaver is active (the screen is blanked), then stop the current graphics demo and run a new one (chosen randomly.) -next This is like either -activate or -cycle, depending on which is more appropriate, except that the graphics hack that will be run is the next one in the list, instead of a randomly-chosen one. In other words, repeatedly executing -next will cause the xscreensaver process to invoke each graphics demo sequentially. (Though using the -demo option is probably an easier way to accomplish that.) -prev This is like -next, but cycles in the other direction. -select number Like -activate, but runs the Nth element in the list of hacks. By knowing what is in the programs list, and in what order, you can use this to activate the screensaver with a particular graphics demo. (The first element in the list is numbered 1, not 0.) -exit Causes the xscreensaver process to exit gracefully. This does nothing if the display is currently locked. Warning: never use kill -9 with xscreensaver while the screensaver is active. If you are using a virtual root window manager, that can leave things in an inconsistent state, and you may need to restart your window manager to repair the damage. -lock Tells the running xscreensaver process to lock the screen immediately. This is like -activate, but forces locking as well, even if locking is not the default (that is, even if xscreensaver's lock resource is false, and even if the lockTimeout resource is non- zero.) Note that locking doesn't work unless the xscreensaver process is running as you. See xscreensaver(1) for details. -version Prints the version of xscreensaver that is currently running on the display: that is, the actual version number of the running xscreensaver background process, rather than the version number of xscreensaver-command. (To see the version number of xscreen- saver-command itself, use the -help option.) -time Prints the time at which the screensaver last activated or deactivated (roughly, how long the user has been idle or non-idle: but not quite, since it only tells you when the screen became blanked or un-blanked.) -restart Causes the screensaver process to exit and then restart with the same command line arguments as last time. You shouldn't really need to do this, since xscreensaver notices when the .xscreensaver file has changed and re-reads it as needed. -watch Prints a line each time the screensaver changes state: when the screen blanks, locks, unblanks, or when the running hack is changed. This option never returns; it is intended for use by shell scripts that want to react to the screensaver in some way. An example of its output would be: BLANK Fri Nov 5 01:57:22 1999 RUN 34 RUN 79 RUN 16 LOCK Fri Nov 5 01:57:22 1999 RUN 76 RUN 12 UNBLANK Fri Nov 5 02:05:59 1999 The above shows the screensaver activating, running three different hacks, then locking (perhaps because the lock-timeout went off) then unblanking (because the user became active, and typed the correct password.) The hack numbers are their index in the `pro- grams' list (starting with 1, not 0, as for the -select command.) For example, suppose you want to run a program that turns down the volume on your machine when the screen blanks, and turns it back up when the screen un-blanks. You could do that by running a Perl program like the following in the background. The following program tracks the output of the -watch command and reacts accordingly: #!/usr/bin/perl my $blanked = 0; open (IN, "xscreensaver-command -watch |"); while (<IN>) { if (m/^(BLANK|LOCK)/) { if (!$blanked) { system "sound-off"; $blanked = 1; } } elsif (m/^UNBLANK/) { system "sound-on"; $blanked = 0; } } Note that LOCK might come either with or without a preceding BLANK (depending on whether the lock-timeout is non-zero), so the above program keeps track of both of them. STOPPING GRAPHICS
If xscreensaver is running, but you want it to stop running screen hacks (e.g., if you are logged in remotely, and you want the console to remain locked but just be black, with no graphics processes running) you can accomplish that by simply powering down the monitor remotely. In a minute or so, xscreensaver will notice that the monitor is off, and will stop running screen hacks. You can power off the monitor like so: xset dpms force off See the xset(1) manual for more info. You can also use xscreensaver-demo(1) to make the monitor power down after a few hours, meaning that xscreensaver will run graphics until it has been idle for the length of time you specified; and after that, the monitor will power off, and screen hacks will stop being run. DIAGNOSTICS
If an error occurs while communicating with the xscreensaver daemon, or if the daemon reports an error, a diagnostic message will be printed to stderr, and xscreensaver-command will exit with a non-zero value. If the command is accepted, an indication of this will be printed to stdout, and the exit value will be zero. ENVIRONMENT
DISPLAY to get the host and display number of the screen whose saver is to be manipulated. PATH to find the executable to restart (for the -restart command). Note that this variable is consulted in the environment of the xscreensaver process, not the xscreensaver-command process. UPGRADES
The latest version of xscreensaver(1) and related tools can always be found at http://www.jwz.org/xscreensaver/ SEE ALSO
X(1), xscreensaver(1), xscreensaver-demo(1), xset(1) COPYRIGHT
Copyright (C) 1992, 1993, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by Jamie Zawinski. Permission to use, copy, modify, dis- tribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No repre- sentations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. AUTHOR
Jamie Zawinski <jwz@jwz.org>, 13-aug-92. Please let me know if you find any bugs or make any improvements. X Version 11 5.15 (28-Sep-2011) xscreensaver-command(1)
All times are GMT -4. The time now is 01:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy