justhink Posted June 5, 2010 Share Posted June 5, 2010 Hi All,I have created following batch file which will read value from a text file and set a variable. But somehow it's not working, to debug, i have added several pause on the file, and found that it's automatically closing after executing FOR statement. But if i execute the for statement on direct command line it's working and also it's setting the variable. Please help me to fix this@echo offpauseFOR /F "tokens=2" %a in (C:\chk.txt) do set _port=%apause::set _reg=openif "%_port%" == "open" ( echo : True : pauseexit)echo : False :pauseexitContent of the chk.txt is:25/tcp open smtpAfter executing FOR statement directly on command prompt.C:\>FOR /F "tokens=2" %a in (C:\chk.txt) do set _port=%aC:\>set _port=openC:\>echo %_port%openC:\> Link to comment Share on other sites More sharing options...
justhink Posted June 5, 2010 Author Share Posted June 5, 2010 Solved!! Link to comment Share on other sites More sharing options...
jaclaz Posted June 5, 2010 Share Posted June 5, 2010 Solved!!...by adding a % sign to have two in front of variables:%a on command line%%a in batch scripthttp://www.boot-land.net/forums/index.php?showtopic=11604@justhinkJust to clear the sense of my post, the plot WITHOUT it:you have a problemyou solved it, and say so WITHOUT telling HOWnoone else will ever be able to benefit from the reported experience and the plot WITH it:you have a problemyou solved itHOW it was solved is postedsomeone else with your same problem may benefit from the reported experience jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted June 5, 2010 Share Posted June 5, 2010 It appears that they received a response from elsewhere first but couldn't be bothered to update us!Need help on creating a batch file. Link to comment Share on other sites More sharing options...
jaclaz Posted June 6, 2010 Share Posted June 6, 2010 It appears that they received a response from elsewhere first but couldn't be bothered to update us!Need help on creating a batch file.Sure, that's the same link. jaclaz Link to comment Share on other sites More sharing options...
justhink Posted June 11, 2010 Author Share Posted June 11, 2010 It appears that they received a response from elsewhere first but couldn't be bothered to update us!Need help on creating a batch file.Sure, that's the same link. jaclazI am extremely sorry for doing so, I was i hurry to solve the problem, and after it solved, i was busy with another problem.So sorry again, and in future i will not do the same.. JusTy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now