DOS - File Read

Ms / Ms/e6550
January 12, 2009 at 00:03:11
Specs: DOS, Intel DUO

Help me in this issue

@echo on
set Path=C:\Temp.txt
for /f "eol=; tokens=1 delims=" %%i in (%Path%) do (set /a no=%%i+1)
echo First %no%
set no=1
echo %no%> %Path%
for /f "eol=; tokens=1 delims=" %%i in (%Path%) do (set /a no1=%%i+1)
echo Final %no1%

Here I am trying to read a number from file and after that trying to set it as 1.
But its setting as "ECHO is on".

I cant find the reason for it.
set no=1
echo %no%> %Path%

Please help me out in this issue

See More: DOS - File Read

Report •

January 12, 2009 at 01:19:20
You shouldn't use a variable called "path" path is a system variable that tells the cmd where to look for executable files like find ect. For a list of variables that are not a good idea to use start a new cmd prompt and type in "set". In general terms everything to the left of the "=" should probably not be used.

Now your actual problem may be further down the line, perhaps in the text file. What is in the text file? You need to give an example to make things easier.

Another problem that springs to mind is this line:

echo %no%> %var%

Obviously you don't want a trailing space but since you variable ends in a number cmd may be interpreting your variable as handle redirection. Try this instead:

>%var% echo %no%

I change the variable because of what I mentioned above.

Report •

January 12, 2009 at 01:36:59
echo ^2>num.txt
set /p no_1st=<num.txt
set /a no_1st+=1

echo 1 >num.txt
set /p no_final=<num.txt

set no

1> and 2> is std-out & std-err redirection

Report •

Related Solutions

Ask Question