PC Review


Reply
Thread Tools Rate Thread

bat script problem with "tokens"

 
 
Kevin
Guest
Posts: n/a
 
      3rd Aug 2004
We use a .bat file script to compile from clearcase and
zip up our software everynight. The first thing the
script does is use the DATE commadn to construct a date
tag for the build:

set MYDATE=%DATE%

set MON_NUM=%MYDATE:~4,2%
set DAY_NUM=%MYDATE:~7,2%
set YEAR=%MYDATE:~10,4%

for /f "tokens=%MON_NUM%" %%a in (
"JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC") do
set MON_NAME=%%a

set t=DEV_%YEAR%%MON_NAME%%DAY_NUM%


Just recently we found the builds being named WITHOUT the
month in them. After some investigation I determined that
the "for" line was failing when the MON_NUM was either 08
or 09... it works for every other one though.

I put in this hack:

IF "%MON_NUM%"=="08" SET MON_NUM=8
IF "%MON_NUM%"=="09" SET MON_NUM=9

which works around the problem. Apparently, it has no
problem with just 8 and 9 only with 08 and 09.

I was hoping to gain some insight into this strange
quirk... any info would be greatly appreciated.
 
Reply With Quote
 
 
 
 
John Phillips
Guest
Posts: n/a
 
      3rd Aug 2004
I'm pretty sure it's because the 'for' command is interpreting the 08 or 09
as base 8 (octal). As for the other months, it doesn't matter, since it's
either obvious (10, 11, 12) or it makes no difference (01-07). This
conforms to (at least) the rules for numbers in C/C++.

You're going to have to strip off the leading 0 somehow...


--
John Phillips
MVP - Windows SDK




"Kevin" <(E-Mail Removed)> wrote in message
news:a75901c47960$e2928150$(E-Mail Removed)...
> We use a .bat file script to compile from clearcase and
> zip up our software everynight. The first thing the
> script does is use the DATE commadn to construct a date
> tag for the build:
>
> set MYDATE=%DATE%
>
> set MON_NUM=%MYDATE:~4,2%
> set DAY_NUM=%MYDATE:~7,2%
> set YEAR=%MYDATE:~10,4%
>
> for /f "tokens=%MON_NUM%" %%a in (
> "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC") do
> set MON_NAME=%%a
>
> set t=DEV_%YEAR%%MON_NAME%%DAY_NUM%
>
>
> Just recently we found the builds being named WITHOUT the
> month in them. After some investigation I determined that
> the "for" line was failing when the MON_NUM was either 08
> or 09... it works for every other one though.
>
> I put in this hack:
>
> IF "%MON_NUM%"=="08" SET MON_NUM=8
> IF "%MON_NUM%"=="09" SET MON_NUM=9
>
> which works around the problem. Apparently, it has no
> problem with just 8 and 9 only with 08 and 09.
>
> I was hoping to gain some insight into this strange
> quirk... any info would be greatly appreciated.



 
Reply With Quote
 
Kevin
Guest
Posts: n/a
 
      3rd Aug 2004
I thought it might be somethign like that but I don't
understand on that basis why 08 doesn't work but 8 does?
What causes the 08 to be interpreted as octal and not 8..
or 18 for that matter (which I also played with).



>-----Original Message-----
>I'm pretty sure it's because the 'for' command is

interpreting the 08 or 09
>as base 8 (octal). As for the other months, it doesn't

matter, since it's
>either obvious (10, 11, 12) or it makes no difference (01-

07). This
>conforms to (at least) the rules for numbers in C/C++.
>
>You're going to have to strip off the leading 0 somehow...
>
>
>--
>John Phillips
>MVP - Windows SDK
>
>
>
>
>"Kevin" <(E-Mail Removed)> wrote in message
>news:a75901c47960$e2928150$(E-Mail Removed)...
>> We use a .bat file script to compile from clearcase and
>> zip up our software everynight. The first thing the
>> script does is use the DATE commadn to construct a date
>> tag for the build:
>>
>> set MYDATE=%DATE%
>>
>> set MON_NUM=%MYDATE:~4,2%
>> set DAY_NUM=%MYDATE:~7,2%
>> set YEAR=%MYDATE:~10,4%
>>
>> for /f "tokens=%MON_NUM%" %%a in (
>> "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC") do
>> set MON_NAME=%%a
>>
>> set t=DEV_%YEAR%%MON_NAME%%DAY_NUM%
>>
>>
>> Just recently we found the builds being named WITHOUT

the
>> month in them. After some investigation I determined

that
>> the "for" line was failing when the MON_NUM was either

08
>> or 09... it works for every other one though.
>>
>> I put in this hack:
>>
>> IF "%MON_NUM%"=="08" SET MON_NUM=8
>> IF "%MON_NUM%"=="09" SET MON_NUM=9
>>
>> which works around the problem. Apparently, it has no
>> problem with just 8 and 9 only with 08 and 09.
>>
>> I was hoping to gain some insight into this strange
>> quirk... any info would be greatly appreciated.

>
>
>.
>

 
Reply With Quote
 
John Phillips
Guest
Posts: n/a
 
      3rd Aug 2004
As I said before, that's the C++ standard...if you want something to be
interpreted as:

- octal, then prefix the value with 0
- hexadecimal, then prefix the value with 0x

Everything else is decimal.

--
John Phillips
MVP - Windows SDK



"Kevin" <(E-Mail Removed)> wrote in message
news:b05f01c47974$9c610df0$(E-Mail Removed)...
> I thought it might be somethign like that but I don't
> understand on that basis why 08 doesn't work but 8 does?
> What causes the 08 to be interpreted as octal and not 8..
> or 18 for that matter (which I also played with).
>
>
>
> >-----Original Message-----
> >I'm pretty sure it's because the 'for' command is

> interpreting the 08 or 09
> >as base 8 (octal). As for the other months, it doesn't

> matter, since it's
> >either obvious (10, 11, 12) or it makes no difference (01-

> 07). This
> >conforms to (at least) the rules for numbers in C/C++.
> >
> >You're going to have to strip off the leading 0 somehow...
> >
> >
> >--
> >John Phillips
> >MVP - Windows SDK
> >
> >
> >
> >
> >"Kevin" <(E-Mail Removed)> wrote in message
> >news:a75901c47960$e2928150$(E-Mail Removed)...
> >> We use a .bat file script to compile from clearcase and
> >> zip up our software everynight. The first thing the
> >> script does is use the DATE commadn to construct a date
> >> tag for the build:
> >>
> >> set MYDATE=%DATE%
> >>
> >> set MON_NUM=%MYDATE:~4,2%
> >> set DAY_NUM=%MYDATE:~7,2%
> >> set YEAR=%MYDATE:~10,4%
> >>
> >> for /f "tokens=%MON_NUM%" %%a in (
> >> "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC") do
> >> set MON_NAME=%%a
> >>
> >> set t=DEV_%YEAR%%MON_NAME%%DAY_NUM%
> >>
> >>
> >> Just recently we found the builds being named WITHOUT

> the
> >> month in them. After some investigation I determined

> that
> >> the "for" line was failing when the MON_NUM was either

> 08
> >> or 09... it works for every other one though.
> >>
> >> I put in this hack:
> >>
> >> IF "%MON_NUM%"=="08" SET MON_NUM=8
> >> IF "%MON_NUM%"=="09" SET MON_NUM=9
> >>
> >> which works around the problem. Apparently, it has no
> >> problem with just 8 and 9 only with 08 and 09.
> >>
> >> I was hoping to gain some insight into this strange
> >> quirk... any info would be greatly appreciated.

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the "None_ploc" SID in process tokens? Walter Porter Windows Vista Security 0 27th Sep 2006 12:44 AM
script language = "js", "jscript", "javascript", "vj#" What to use =?Utf-8?B?UkZTNjY2?= Microsoft ASP .NET 7 28th Oct 2005 12:52 PM
Script to "Net Use", enable "Offline", install "twcli32.msi" autom =?Utf-8?B?VGVyZW5jZQ==?= Microsoft Windows 2000 File System 0 23rd Dec 2004 06:55 AM
Re: Problem with Response.Write("<script>alert('" + errorMessage + "') William F. Robertson, Jr. Microsoft ASP .NET 2 14th Aug 2004 12:44 AM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:27 AM.