Saved Bookmarks
| 1. |
Solve : Batch file write variables to file? |
|
Answer» Quote from: Linux711 on June 09, 2010, 07:21:57 PM The problem is that it does not write the variables to the file. It only partially works when I remove the whole if statement. . I thought this was because I have a space before the >>, but when I remove the space it doesn't work at all. So can someone that understands this convoluted language HELP me figure this out? There is no problem. A TRAILING space for a redirect ( >> ) does not CAUSE a problem. There is no need to remove the trailing space. This complete thread is nonsense. Quote from: marvinengland on June 11, 2010, 01:16:23 PM This complete thread is nonsense. The parts that you contributed are. Why don't you leave? Please. Quote There is no problem. A trailing space for a redirect ( >> ) Don't you REALIZE that there might be something other than human eyes reading this file. @BC_Programmer Thank you. The escape ^ works. I adjusted the code a little. Removed the !in! !in2! !in3! and just made everything !in! because there is no point in using a new variable each time. I also fixed the file name issue. Here is the final code. It works perfectly. No need for any more arguments. Code: [Select]@echo off setlocal enabledelayedexpansion set /p yorn=Would you like to setup the server name etc.(y/n)? if /i %yorn%==y ( set /p in=Maximum clients: echo maxclients !in!> bla.cfg set /p in=Bot limit: echo serverbotlimit !in!>> bla.cfg echo publicserver ^0>>bla.cfg set /p in=Server title: echo serverdesc "!in!">> bla.cfg ) else ( echo said no. ) PS: Does anyone know how to mark resolved on this forum?Quote from: marvinengland on June 11, 2010, 01:16:23 PM A trailing space for a redirect ( >> )@echo off echo Comparing requires no trailing spaces > file.txt set /p var=if not "Comparing requires no trailing spaces"=="%var%" echo FAIL! pause It is also affects FTP scripts, too. Just so you know. |
|