Re: Need Help With Script
- From: "Will" <westes-usc@xxxxxxxxxxxxxx>
- Date: Sun, 21 Sep 2008 14:47:01 -0700
"Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message
news:ufm5Q7BHJHA.740@xxxxxxxxxxxxxxxxxxxxxxx
file:
"Will" <westes-usc@xxxxxxxxxxxxxx> wrote in message
news:zeidnW4I44EhB0vVnZ2dnUVZ_oWdnZ2d@xxxxxxxxxxxxxxx
I need help with a simple script. I want to put the output of a command
into an environment variable, and I tried this construction in a CMD
with
for /f "usebackq delims=" %%i in (`D:\USR\BINTU\MKSNT\date +%a`) do set
dayofweek=%%i
The moment this line of the script executes, the script is terminated
dayofweek=%%ino error. It looks to me like the date.exe command I am calling is
exiting
in a way that doesn't allow a return back to the script that called it.
The %dayofweek% environment variable is NOT being set.
Any thoughts on how I can get this to work?
--
Will
Did you try this somewhat simplified syntax?
@echo off
for /f "delims=" %%i in ('D:\USR\BINTU\MKSNT\date +%a') do set
A few questions:
- What's %a? If it's a loop variable (perhaps from an outer loop)
then it should be %%a.
- What's the + in front of %a? A switch marker?
- When you execute the command
D:\USR\BINTU\MKSNT\date > c:\test.txt
and examine c:\test.txt with a binary viewer (e.g. debug.exe), what
exactly do you see? Is it an ASCII file? Unicode? What are the last
few characters in the file?
The date.exe I am executing here is a Windows version of the Unix Date
command. The command:
date +%a
will give the three letter code for the day of the week. On Sunday it
would give output:
Sun
So to answer your question "%a" is NOT a loop variable from elsewhere in the
script. It is a literal text input string that is interpreted by the date
command for purposes of selecting an output.
Redirection of this command from the command line to a file put the
appropriate output there without any problems. Inspecting this output file
with debug gave the expected result of three ASCII characters followed by
0xD 0xA.
I tried your simplified syntax without usebackq or backquotes and the script
still dies in the same place.
--
Will
.
- Follow-Ups:
- Re: Need Help With Script
- From: Pegasus \(MVP\)
- Re: Need Help With Script
- References:
- Need Help With Script
- From: Will
- Re: Need Help With Script
- From: Pegasus \(MVP\)
- Need Help With Script
- Prev by Date: Locating the assembly DLL and it's Version ??
- Next by Date: Re: Locating the assembly DLL and it's Version ??
- Previous by thread: Re: Need Help With Script
- Next by thread: Re: Need Help With Script
- Index(es):
Relevant Pages
|