----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

DOWN IN THE DETAILS - 20030129

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

THE ANNOUNCING ISSUE - 20030101 | THE FIRING ISSUE - 20030108 | A TRIP UP THE CLIFFS OF IF - 20030115 | AIRBORNE ON SET RIDGE - 20030122 | DOWN IN THE DETAILS - 20030129 | TREASURES IN THE SAND - 20030205 | A PLAIN PATH THRU FOREST FINDSTR - 20030212

Are you Booming or Fuming?

DOWN IN THE DETAILS - 20030129!

We've been "AIRBORNE" all week with a solid hold on our "Threefold Cord of Knowledge"!  This week, we're going to get down in the details about the gear we've brought with us!

We're also going for another climb up the Cliffs of IF!

. . . and there's a Flying Rumor in the camp!



Joe Fumer
is feeling better and stronger each week.
He's up in FRONT of the pack on this trip!

"Scaling cliffs?!  NO PROBLEM!", says Joe!


One of the most critical items we've brought with us is our .Mount/\Command Set. Our current version (Release 2002.10.18) has seen us through many Fuming Days and brought Compatibility, Clarity and Speed to our scripts.  We can actually read and understand our scripts now, even the ones we wrote a long time ago.  I'll tell you this much, "We're never going back to the old way!".

But we've heard a Flying Rumor of a new .Mount/\Command Set coming in February 2003 that DOUBLES the number of included .Mount/\Commands while compressing MtCmds.cmd to less than half it's current size!

We can't wait to sink our teeth into that one!



.Mount/\Commands are divided into logical groups to provide CONSISTENCY in naming, syntax and behavior. The ".Get[Value]" Series of commands perform three tasks:

  1. Retrieve, optionally reformat and display a single value to the console.
  2. Place the retrieved value in a variable named #Value.
  3. Set an errorlevel, if applicable, based on the result.

For example, the .GetOS command we have been using in our examples (1) retrieves and displays the OS, (2) saves the value in variable %#OS%, and (3) sets an errorlevel indicating the result.

When we retrieve our value in task (1), it may not be in a suitable format for use in a script.  Depending upon the operating system and the system configuration, many commands will add, delete or rearrange characters and words, causing much grief.


For example, the command "TIME/T" returns the following (English-US):

C:\NT> 4:24a

C:\2K> 4:24a

C:\XP>04:24 AM

C:\K3>04:24 AM

Now there's one to make the FUMES FLY OK, How about this...

    ECHO:Y|TIME|FindStr [0-9]

C:\NT>The current time is: 4:30:34.22

C:\2K>The current time is: 4:30:34.22

C:\XP>The current time is: 4:30:34.22

C:\K3>The current time is: 4:30:34.22

Well, that's closer but now we need to extract just the time.  Ignoring the fractional seconds (.22), here's a third try...

    @(FOR /F "tokens=5-7 delims=.:, " %%A IN (
        'ECHO:Y^|TIME^|FindStr [0-9]') DO @(
            (ECHO:%%A:%%B:%%C)
        )
    )

C:\NT>4:30:34

C:\2K>4:30:34

C:\XP>4:30:34

C:\K3>4:30:34


Looks great, but what happens at 10:00:00?  We have to get the "Cord of Compatibility" around that hour so it always has a leading zero when it's less than 10. Now your common sense would tell you that the following SHOULD work:

@(
   FOR /F
"tokens=5-7 delims=.:, " %%A IN (
      'ECHO:Y^|TIME^|FindStr [0-9]') DO @(
         (IF %%A LSS 10 (
            (ECHO:0%%A:%%B:%%C)
         ) ELSE (
            (ECHO:%%A:%%B:%%C)
         )
      )
   )
)

C:\NT>

C:\2K>04:30:34

C:\XP>04:30:34

C:\K3>04:30:34


Well...it don't!

There are many loose rocks on the "Cliffs of IF" and we just discovered one. The NT Face of these cliffs has been weathered down since it was discovered way back in '96.  It's a good thing our group is ALL HARNESSED TOGETHER with the "Threefold Cord of Knowledge" or we would have surely lost Joe Fumer!

Under NT, the IF command will not perform comparisons properly after the -DO- in a FOR loop. "I guess we're at the end of the road!", fumes Joe, still shook up from his near fall, "we'll just settle for a rush job and deal with the fallout later!"

(better let some of the more experienced climbers lead the way next time, Joe!)


As always, the answer is right here on Mount Knowledge, just slightly hidden from [Joe's] view! Let's have a look.

@(FOR /F "tokens=5-7 delims=.:, " %%A IN (
    'ECHO:Y^|TIME^|FindStr [0-9]') DO @(
        (ECHO:%%A|FindStr/br [0-9][0-9] >NUL^
        &&(ECHO:%%A:%%B:%%C)^
        ||(ECHO:0%%A:%%B:%%C)^
        )
    )
)

C:\NT>04:30:34

C:\2K>04:30:34

C:\XP>04:30:34

C:\K3>04:30:34


TWO MORE STEPS and we'll have a .Mount/\Command...


STEP ONE: Add a SET statement to save the retrieved and reformatted time to %#Time% as well as ECHOing it.

@(FOR /F "tokens=5-7 delims=.:, " %%A IN (
    'ECHO:Y^|TIME^|FindStr [0-9]') DO @(
        (ECHO:%%A|FindStr/br [0-9][0-9] >NUL^
        &&((SET #Time=%%A:%%B:%%C)&(ECHO:%%A:%%B:%%C))^
        ||((SET #Time=0%%A:%%B:%%C)&(ECHO:0%%A:%%B:%%C))^
        )
    )
)


STEP TWO: Apply the Cord of Speed Pattern Script (see BoF-20030122) to compress the entire statement into one line of code, and save it to the .M/\C called ".GetTime".

(The below is all one line)

@SET ".GetTime=(@(FOR /F "tokens=5-7 delims=.:, " %%A IN ('ECHO:Y^|TIME^|FindStr [0-9]') DO @((ECHO:%%A|FindStr/br [0-9][0-9] >NUL&&((SET #Time=%%A:%%B:%%C)&(ECHO:%%A:%%B:%%C))||((SET #Time=0%%A:%%B:%%C)&(ECHO:0%%A:%%B:%%C))))))"

C:\>%.GetTime%
04:30:34


There are several other commands in the .Get[Value] series to process [Values] such as IP Addresses, Dates, etc.  And you can easily add your own commands using the Pattern Scripts that we provide.  All of the .Mount/\Commands (ours and yours) will behave CONSISTENTLY across operating systems, and can be loaded or unloaded as a group with one line of code!



Joe
has learned a valuable lesson about haste this week.

There is a reason that Speed comes AFTER Compatibility
and Clarity.  It only pays to be fast if you know that you're going in the right direction, and WHY you're going that way!

"I'm sure glad we were all harnessed together with the
Threefold Cord of Knowledge!", says Joe.


.GetTime and 50 other .Mount/\Commands are included in the FREE Advanced NT/2K/XP Command Library.

The  "Almost Free" Expert NT/2K/XP Command Library includes over 300 .M/\Cs plus dozens of other Resources --AND- the $WAITFOR function.  The Expert Library is available for $9 or less (quantity discounts start at 5 or more).

Here's the (abridged) help screen for $WAITFOR:

  ^   =========================================================================
 /!\   NTCmdLib.cmd 2002.10.18 NT/2K/XP ("Almost Freeware" at $9 or less!)
/LIB\ =========================================================================

$WAITFOR WaitTime RefreshInterval "[Command/Program]"

  Waits for the requested time, then executes [optional] Command.

  NTCmdLib $WAITFOR 120 30 "dailybackup.cmd"

  WaitTime        = How long to wait (in minutes)
  RefreshInterval = How often to update the console status message (in minutes)

  "Command/Program" = Optional Command/Program to execute after waiting.

  If no "Command" is specified, a default of "%.rem%" will be executed.


C:\GuardPost>NTCmdLib /q $WAITFOR 5 1 "ECHO:We're movin' on!"

[Wed 01/29/2003 14:47:24] 5 minute(s) left...
[Wed 01/29/2003 14:48:24] 4 minute(s) left...
[Wed 01/29/2003 14:49:24] 3 minute(s) left...
[Wed 01/29/2003 14:50:24] 2 minute(s) left...
[Wed 01/29/2003 14:51:24] 1 minute(s) left...
[Wed 01/29/2003 14:52:24] WAITFOR Completed.
We're movin' on!


The complete  .Mount/\Command Set is also available separately in a standalone script (MtCmds.cmd) for $7 or less.

We can confirm the Flying Rumor of a GREATLY EXPANDED (in functions and features) and GREATLY COMPRESSED (in size and execution time) .Mount/\Command Set due out in February, 2003!

Upgrade discounts (from Release 2002.10.18 only) will be at the normal discount rate of 50% off the total upgrade price.  All .Mt/\Cmd purchases on or after 20030129 will automatically receive the new Command Set when it is released.

For a limited time, we're also offering 10% discounts to all new orders from User Groups and their members. See our Monthly Specials for more information.


All of our products are completely written using ONLY what is available in ALL INSTALLATIONS of Windows NT 4 SP6a, Windows 2000, Windows XP and Windows Server 2003.  There is no binary code, only scripting commands.

They perform CONSISTENTLY across all supported platforms (see the Compatibility page) and require no installation or uninstallation.


To start receiving BoomingOrFuming?, first register, then follow the instructions on the contact page.

Space is limited and time is short, so reserve your spot today!

We'll take you up the Mountain of Knowledge, which rises higher than all the other Hills of Confusion.

/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\