batch file problem

  • Thread starter Thread starter jg
  • Start date Start date
J

jg

I hope this the right group:

my .bat file seems to set environment variable from result of vbscript
but the value disappear right away!!. I said that because I saw the output

c:\>set DtRapidLstDnlod=2005-11-29 18:38:00
from the bat file was executing the line
echo 2005-11-29 18:38:00| For /F "usebackq tokens=1-2" %%i in (`cscript
//nologo "D:\util\ConvertMMM_DD_HH_MM.vbs" `) do set
DtRapidLstDnlod=%%i %%j

in a nut shell the problematic bat file statement are
echo 2005-11-29 18:38:00 | For /F "usebackq tokens=1-2" %%i in (`cscript
//nologo
"D:\util\ConvertMMM_DD_HH_MM.vbs" `) do set DtRapidLstDnlod=%%i %%j
echo @debug DtRapidLstDnlod=%DtRapidLstDnlod%
@@rem the line above shows no value in
@@rem end of bat file
Now I see output

c:\>set DtRapidLstDnlod=2005-11-29 %J

@debug DtRapidLstDnlod=


here is the code for vbs file
dim newDt , sDt, str
str = wscript.stdIn.ReadLine
newDt = Cdate(str)
sDt = "" & newDT
if len(sDt) = 17 then
sDt = "20" & sDt
End If

wscript.echo sDt

where did I go wrong? or is there a better to get result out of a script
excution.

from the output the vbscript does seem to function correctly, but somehow,
the value of variable being set gets lost. and become some funny empty
value.

I would have used vbscript for the entire task except I get in trouble with
some file IO after using FTP. At times the redirected output of FTP
is not availabe to the script when it should.. Furthermore, I already have
a template for the batch file for the task.
 
Every program gets a copy of the program that started them environment. Therefore CScript environment gets changed, then thrown away when it exits.
 
jg said:
I hope this the right group:

my .bat file seems to set environment variable from result of vbscript
but the value disappear right away!!. I said that because I saw the
output

c:\>set DtRapidLstDnlod=2005-11-29 18:38:00
from the bat file was executing the line
echo 2005-11-29 18:38:00| For /F "usebackq tokens=1-2" %%i in
(`cscript
//nologo "D:\util\ConvertMMM_DD_HH_MM.vbs" `) do set
DtRapidLstDnlod=%%i %%j

in a nut shell the problematic bat file statement are
echo 2005-11-29 18:38:00 | For /F "usebackq tokens=1-2" %%i in (`cscript
//nologo
"D:\util\ConvertMMM_DD_HH_MM.vbs" `) do set DtRapidLstDnlod=%%i %%j
echo @debug DtRapidLstDnlod=%DtRapidLstDnlod%
@@rem the line above shows no value in
@@rem end of bat file
Now I see output

c:\>set DtRapidLstDnlod=2005-11-29 %J

@debug DtRapidLstDnlod=


here is the code for vbs file
dim newDt , sDt, str
str = wscript.stdIn.ReadLine
newDt = Cdate(str)
sDt = "" & newDT
if len(sDt) = 17 then
sDt = "20" & sDt
End If

wscript.echo sDt

where did I go wrong? or is there a better to get result out of a script
excution.

from the output the vbscript does seem to function correctly, but somehow,
the value of variable being set gets lost. and become some funny empty
value.

I would have used vbscript for the entire task except I get in trouble
with
some file IO after using FTP. At times the redirected output of FTP
is not availabe to the script when it should.. Furthermore, I already
have
a template for the batch file for the task.

For /F "usebackq tokens=1-2" %%i in (`echo 2005-11-29 18:38:00^|cscript
//nologo "D:\util\ConvertMMM_DD_HH_MM.vbs" `) do set DtRapidLstDnlod=%%i
%%j

HTH

....Bill
 
true but the vbs script does not alter env but send to stdout the result of
conversion and that the output the For command picks up via the usebackq
option.

Furthermore I saw the set command of the DO part of the FOE command executed
but the value set was rather transient

Billiour showed the use of caret before the pipe to bar works like a charm
however.

"David Candy" <.> wrote in message
Every program gets a copy of the program that started them environment.
Therefore CScript environment gets changed, then thrown away when it exits.
 
jg said:
thank you



what does the caret in front for the pipe to symbol mean?

It escapes the pipe, telling DOS that it's a part of the command within the
backquotes, not an attempt to pipe [what is before the pipe] to [what is
after] since piping [For /F "usebackq tokens=1-2" %%i in (`echo 2005-11-29
18:38:00] to cscript... is unlikely to make much sense.

HTH

....Bill
 
Back
Top