script progress

  • Thread starter Thread starter Stel
  • Start date Start date
S

Stel

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.
 
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.

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
 
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

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
 
Tom,

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

Stel
 
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
 
Tom Lavedas said:
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
 
Tom Lavedas said:
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
 
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
 
Tom said:
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 said:
Wow! I had no idea you could do this in a cmd script! Awesome!

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
 
Back
Top