Jump to content

Scripts not passing variables


Kleston

Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 14 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use