Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

script progress

13 views
Skip to first unread message

Stel

unread,
Sep 3, 2009, 4:12:49 PM9/3/09
to
I was just wondering if anyone had a good way of showing progress of a
Command Shell Script? Something like the "WScript.StdOut.Write ". "
in Cscript would be cool.

Stel

unread,
Sep 3, 2009, 4:46:24 PM9/3/09
to

about the best I've come up with is something like this.

Have a variable dots and in the loop put

set dots=%dots%.
cls
echo %dots%

The variable %dots% would have a period or dot added to it each time
the loop ran then it would clear the screen and echo the growing
string of dots. Maybe in the Title put "Script in progress" or
something?

Thoughts??? I'd really like to have a few lines above this. What
about CrLf in the variable when I first set it???

Stel

Tom Lavedas

unread,
Sep 3, 2009, 5:10:38 PM9/3/09
to

All you need is the equivalent of the Write (without a new line),
which in batch is the SET /P with the NUL device redirected into
STDIN. For example ...

@echo off
set /p =Patience, please <nul
for /l %%a in (1,1,25) do (
set /p =.<nul
ping -n 2 127.0.0.1 > nul
)
echo. Thank you for waiting.
_____________________
Tom Lavedas

Stel

unread,
Sep 4, 2009, 10:39:54 AM9/4/09
to
Tom,

That is elegant and simple. Very nice. Much better than the road I
was going down. Thanks man.

Stel

Tom Lavedas

unread,
Sep 4, 2009, 11:20:21 AM9/4/09
to

You're entirely welcome.

BTW, here's a variation on the theme that makes the technique a little
easier to use ...

@echo off
setlocal
set "write=<nul set/p"
%write%=Patience, please


for /l %%a in (1,1,25) do (

%write%=Ü


ping -n 2 127.0.0.1 > nul
)
echo. Thank you for waiting.

Also note the Ü character (Alt-0220 in Notepad), which displays a more
'progress bar' like character in the console's standard US code page.
_____________________
Tom Lavedas

Al Dunbar

unread,
Sep 9, 2009, 6:24:56 PM9/9/09
to

"Tom Lavedas" <tglb...@cox.net> wrote in message
news:3bb5334e-edae-44bd...@t13g2000yqn.googlegroups.com...

> On Sep 4, 10:39 am, Stel <kstel...@sbcglobal.net> wrote:
>> Tom,
>>
>> That is elegant and simple. Very nice. Much better than the road I
>> was going down. Thanks man.
>>
>> Stel
>
> You're entirely welcome.
>
> BTW, here's a variation on the theme that makes the technique a little
> easier to use ...
>
> @echo off
> setlocal
> set "write=<nul set/p"
> %write%=Patience, please
> for /l %%a in (1,1,25) do (
> %write%=�

> ping -n 2 127.0.0.1 > nul
> )
> echo. Thank you for waiting.
>
> Also note the � character (Alt-0220 in Notepad), which displays a more

Al Dunbar

unread,
Sep 9, 2009, 6:48:26 PM9/9/09
to

"Tom Lavedas" <tglb...@cox.net> wrote in message
news:3bb5334e-edae-44bd...@t13g2000yqn.googlegroups.com...
> On Sep 4, 10:39 am, Stel <kstel...@sbcglobal.net> wrote:
>> Tom,
>>
>> That is elegant and simple. Very nice. Much better than the road I
>> was going down. Thanks man.
>>
>> Stel
>
> You're entirely welcome.
>
> BTW, here's a variation on the theme that makes the technique a little
> easier to use ...
>
> @echo off
> setlocal
> set "write=<nul set/p"
> %write%=Patience, please
> for /l %%a in (1,1,25) do (
> %write%=�

> ping -n 2 127.0.0.1 > nul
> )
> echo. Thank you for waiting.
>
> Also note the � character (Alt-0220 in Notepad), which displays a more

> 'progress bar' like character in the console's standard US code page.
> _____________________
> Tom Lavedas

Another useful option is the TITLE command, which allows you to modify the
text in the title bar of the window. Depending on what the script itself is
doing, this will even be updated on the task bar button when the window is
minimized.

/Al

Stel

unread,
Sep 10, 2009, 7:52:18 AM9/10/09
to
>
> Another useful option is the TITLE command, which allows you to modify the
> text in the title bar of the window. Depending on what the script itself is
> doing, this will even be updated on the task bar button when the window is
> minimized.
>
> /Al

Thanks Al. I tried that. Presently I put the script name and the
time script started in the Title bar. Tom nailed this. Works great.

Stel

David Trimboli

unread,
Sep 28, 2009, 9:25:07 AM9/28/09
to
Tom Lavedas wrote:
>> On Sep 3, 3:12 pm, Stel <kstel...@sbcglobal.net> wrote:
>>
>>> I was just wondering if anyone had a good way of showing progress of a
>>> Command Shell Script? Something like the "WScript.StdOut.Write ". "
>>> in Cscript would be cool.
>> about the best I've come up with is something like this.
>
> All you need is the equivalent of the Write (without a new line),
> which in batch is the SET /P with the NUL device redirected into
> STDIN. For example ...
>
> @echo off
> set /p =Patience, please <nul
> for /l %%a in (1,1,25) do (
> set /p =.<nul
> ping -n 2 127.0.0.1 > nul
> )
> echo. Thank you for waiting.

Wow! I had no idea you could do this in a cmd script! Awesome!

--
David Trimboli
Windows Systems Analyst
Cold Spring Harbor Laboratory

Al Dunbar

unread,
Oct 2, 2009, 7:39:05 PM10/2/09
to

"David Trimboli" <trim...@cshl.edu> wrote in message
news:#ucEY8DQ...@TK2MSFTNGP05.phx.gbl...

Yes, way cool. But the tricky part is to see that progress bar growing while
the script is doing actual work rather than generating short delays...

Simplest would seem to be to intersperse calls to an internal routine that
uses set/p to output a period without a new line, I.e.:

do some stuff
call:showdot
do some more stuff
call:showdot

The next difficult part is for the progress bar to indicate not only that
something is happening, but how close to completion it is getting. That can
be tricky, depending on what the script is trying to do.

/Al

0 new messages