Hooking two batch files together with set values (premature exit?) -


one problem crashes trying call createserver.bat @ end of this

del %userprofile%\desktop\terrariaserver\filebin\serverparams.cmd wget http://***/serverparams.cmd  call serverparams.cmd  if name==default ( del %userprofile%\desktop\terrariaserver\filebin\serverparams.cmd call senderror.bat ) else ( randomport -default -defaut -default timeout /t 1 )  if not name==default ( sysresourceoutput timeout /t 5 call sysresources if %ram% gtr 1600 ( call %userprofile%\desktop\terrariaserver\createserver.bat ) ) 

though createserver.bat alone runs fine.

another problem linking set values calling serverparams.cmd.. or setting serverparams values correctly @ all, using above, though running through series of commands in startserver below a-ok (in base directory).

call setname.cmd call setvars.cmd  set path=%userprofile%\desktop\terrariaserver  echo set port=%var1% >%path%\%name%_set.cmd echo set players=%var2% >>%path%\%name%_set.cmd echo set autocreate=%var3% >>%path%\%name%_set.cmd echo set worldname=%var4% >>%path%\%name%_set.cmd echo set password=%var5% >>%path%\%name%_set.cmd echo set motd=%var6% >>%path%\%name%_set.cmd echo set lang=%var7% >>%path%\%name%_set.cmd echo set priority=%var8% >>%path%\%name%_set.cmd echo set name=%name% >>%path%\%name%_set.cmd  call %name%_set.cmd  echo maxplayers=%players% >%path%\%name%_config.txt echo world=%userprofile%\documents\my games\terraria\worlds\%worldname%.wld >>%path%\%name%_config.txt echo port=%port% >>%path%\%name%_config.txt echo password=%password% >>%path%\%name%_config.txt echo motd=%motd% >>%path%\%name%_config.txt echo worldpath=%userprofile%\documents\my games\terraria\worlds\ >>%path%\%name%_config.txt echo secure=1 >>%path%\%name%_config.txt echo lang=%lang% >>%path%\%name%_config.txt echo upnp=0 >>%path%\%name%_config.txt echo #npcstream=60 >>%path%\%name%_config.txt echo priority=%priority% >>%path%\%name%_config.txt  echo if exist "%userprofile%\documents\my games\terraria\worlds\%worldname%" ( >%path%\%name%_start.bat echo terrariaserver -config %path%\%name%_config.txt >>%path%\%name%_start.bat echo ) else ( >>%name%_start.bat echo terrariaserver -config %path%\%name%_config.txt -port %port% -players %players% -world "%userprofile%\documents\my games\terraria\worlds\%worldname%.wld" -autocreate %autocreate% -worldname %worldname%.wld >>%path%\%name%_start.bat echo ) >>%path%\%name%_start.bat  call %path%\%name%_start.bat 

my question is, there nuances i'm missing? think there's more dynamic way list set of incrementing variables, other manually naming them var01, var02

also, puts space after %worldname%, i'm ok that.

lines never execute there no %variables% evaluate, comparing static strings aren't same.

if name==default (

lines fail when user profile contains spaces or & characters. solution enclose entire "path\filename" in double quotes:

del "%userprofile%\desktop\terrariaserver\filebin\serverparams.cmd"

lines should edited include redirection @ start of line. solves spaces @ end of each line.

echo set port=%var1% >%path%\%name%_set.cmd

rewrite lines in manner , remove trailing spaces

>"%path%\%name%_set.cmd" echo set port=%var1% >>"%path%\%name%_set.cmd" echo set players=%var2% 

include double quotes cater long pathname\filename elements, , change %path% name else path system variable , using break everything.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -