Hi,
Is it possible to use the output that is echoed by a command in DOS 7.1?. The for /f does not exist in 7.1.
I use the find command:
type file.txt|find "string" /c
It returns me a number.
I can send the result to another file like this
find "string" < inputfile > outpufile
But i need to send it to a variable.
Thanks for the help.
DOS 7.1 Use command output in variable
Moderator: DosItHelp
Re: DOS 7.1 Use command output in variable
'
You could use SET2VAR.EXE
$MAC now contains the result, in your situation you'll need type "$file" |set2var $var
SET2VAR.EXE can be found inside the netbootdisk http://netbootdisk.com/![Smile :)](./images/smilies/icon_smile.gif)
You could use SET2VAR.EXE
Code: Select all
"%Drive.RAM%\SHOWMENU.EXE" Finding MAC Address
rem ::(
"%Drive.RAM%\NBMAC.EXE"
"%Drive.RAM%\NBMAC.EXE" |> "%Drive.RAM%\OUT.BAT" "%Drive.RAM%\SET2VAR.EXE" MAC
rem ::
call "%Drive.RAM%\OUT.BAT"
rem ::)
$MAC now contains the result, in your situation you'll need type "$file" |set2var $var
SET2VAR.EXE can be found inside the netbootdisk http://netbootdisk.com/
![Smile :)](./images/smilies/icon_smile.gif)
Re: DOS 7.1 Use command output in variable
This seems to be totally what i'm looking for but i am not able to make it work.
I use this simple command:
type allo.txt|find "1.10" /c|set2var cnt
it work and echo @set cnt=2 but im in the same problem as before, i still can't use the value of cnt in a command.
I need to write:
Type cnt
to see the value.
the command echo %cnt% tell me echo is on instead of 2.
I'm new to Dos so i probably did something wrong but can't figure it out.
I use this simple command:
type allo.txt|find "1.10" /c|set2var cnt
it work and echo @set cnt=2 but im in the same problem as before, i still can't use the value of cnt in a command.
I need to write:
Type cnt
to see the value.
the command echo %cnt% tell me echo is on instead of 2.
I'm new to Dos so i probably did something wrong but can't figure it out.
Re: DOS 7.1 Use command output in variable
'
The guy from NetBootDisk wrote Set2Var himself, he also ownes the copyright.
What you are looking for is explained at his site.
set2var was designed in such a way that it writes set $var=? to TempBatchFile.bat.
The only thing you need to do now is call TempBatchFile.bat.
It's really easy to write your own Set2Var.EXE application. It only takes about 5 assembly instructions.
Unfortunately I have zero knowledge of the x86 instruction set.
I hope to learn this myself someday or be teached by someone.
Does anyone know a good x86 ASM forum ?
Beware, DOS 7.1 was designed to do simple scripting only. Did you know it supports QBASIC.
The MS installer was written in it. It's a powerfull language and a lot of fun.
If you like scripting, QBASIC supports it![Smile :)](./images/smilies/icon_smile.gif)
The guy from NetBootDisk wrote Set2Var himself, he also ownes the copyright.
What you are looking for is explained at his site.
Code: Select all
SET2VAR v0.2 - Freeware - By Brad Driver - Google 'SET2VAR.EXE' for help!
For helping with piping the output of a program to an environment variable
eg: >SomeApp.exe|set2var.exe VarName>TempBatchFile.bat
Druk op een toets om door te gaan. . .
The only thing you need to do now is call TempBatchFile.bat.
It's really easy to write your own Set2Var.EXE application. It only takes about 5 assembly instructions.
Unfortunately I have zero knowledge of the x86 instruction set.
I hope to learn this myself someday or be teached by someone.
Does anyone know a good x86 ASM forum ?
Beware, DOS 7.1 was designed to do simple scripting only. Did you know it supports QBASIC.
The MS installer was written in it. It's a powerfull language and a lot of fun.
If you like scripting, QBASIC supports it
![Smile :)](./images/smilies/icon_smile.gif)
Last edited by Ed Dyreen on 04 Aug 2011 14:17, edited 3 times in total.
Re: DOS 7.1 Use command output in variable
Good.
You are awesome so fast answer and you solved my problem.
Thanks a lot.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Thanks a lot.