Computing.Net > Forums > Programming > DOS - File Read

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

DOS - File Read

Reply to Message Icon

Name: trusp
Date: January 12, 2009 at 00:03:11 Pacific
OS: DOS
CPU/Ram: Intel DUO
Manufacturer/Model: Ms / Ms/e6550
Subcategory: Batch
Comment:

Hi

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


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: January 12, 2009 at 01:19:20 Pacific
Reply:

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 Offensive Follow Up For Removal

Response Number 2
Name: reno
Date: January 12, 2009 at 01:36:59 Pacific
Reply:

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 Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: DOS - File Read

DOS - File Read for environment var www.computing.net/answers/programming/dos-file-read-for-environment-var/17776.html

C++ File Reading www.computing.net/answers/programming/c-file-reading/16213.html

Old dos file www.computing.net/answers/programming/old-dos-file/725.html