Kleston Posted December 3, 2014 Share Posted December 3, 2014 I have the following script set up as a custom icon for the user to execute to update the config file. #!/bin/bash sed -i 's/name="ServerPort"\s*value=".*"/name="ServerPort" value="%ThisService_GamePort%"/g' serverconfig.xml; sed -i 's/name="ServerMaxPlayerCount"\s*value=".*"/name="ServerMaxPlayerCount" value="%ThisService_Slots%"/g' serverconfig.xml; sed -i 's/name="ControlPanelPort"\s*value=".*"/name="ControlPanelPort" value="%ThisService_RConPort%"/g' serverconfig.xml; sed -i 's/name="TelnetPort"\s*value=".*"/name="TelnetPort" value="%ThisService_QueryPort%"/g' serverconfig.xml; Unfortunately when it's run, it does not pass the variable results, just the variable name. Has anyone else come across this issue? Link to comment Share on other sites More sharing options...
xai Posted December 4, 2014 Share Posted December 4, 2014 Hi, http://help.tcadmin.com/Custom_Scripts Example from the help page above: you can use the TCAdminFolder variable. Windows batch script: %TCAdminFolder% Linux shell script: ${TCAdminFolder} Iron Python: TCAdminFolder Cheers Xai Link to comment Share on other sites More sharing options...
Dennis Posted December 4, 2014 Share Posted December 4, 2014 You're using the Windows variables. You need to use the ones for Linux. #!/bin/bash sed -i 's/name="ServerPort"\s*value=".*"/name="ServerPort" value="${ThisService_GamePort}"/g' serverconfig.xml; sed -i 's/name="ServerMaxPlayerCount"\s*value=".*"/name="ServerMaxPlayerCount" value="${ThisService_Slots}"/g' serverconfig.xml; sed -i 's/name="ControlPanelPort"\s*value=".*"/name="ControlPanelPort" value="${ThisService_RConPort}"/g' serverconfig.xml; sed -i 's/name="TelnetPort"\s*value=".*"/name="TelnetPort" value="${ThisService_QueryPort}"/g' serverconfig.xml; Link to comment Share on other sites More sharing options...
Kleston Posted December 4, 2014 Author Share Posted December 4, 2014 Yea I pasted the wrong copy initially in here. I do have linux variables but it still just passes the variable phrase rather than the actual service variable. If i throw in an echo to print the variable the echo works, it's just not passing with the script to the file. Link to comment Share on other sites More sharing options...
Kleston Posted December 4, 2014 Author Share Posted December 4, 2014 Ahh, problem solved, i had to quote the variable so it's outside of the sed call. #!/bin/bash sed -i 's/name="ServerPort"\s*value=".*"/name="ServerPort" value="'${ThisService_GamePort}'"/g' serverconfig.xml; sed -i 's/name="ServerMaxPlayerCount"\s*value=".*"/name="ServerMaxPlayerCount" value="'${ThisService_Slots}'"/g' serverconfig.xml; sed -i 's/name="ControlPanelPort"\s*value=".*"/name="ControlPanelPort" value="'${ThisService_QueryPort}'"/g' serverconfig.xml; sed -i 's/name="TelnetPort"\s*value=".*"/name="TelnetPort" value="'${ThisService_RConPort}'"/g' serverconfig.xml; 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