View previous topic :: View next topic |
Author |
Message |
Zarathustra217
Joined: 15 Aug 2011 Posts: 5
|
Posted: Mon Aug 15, 2011 13:40 Post subject: Running NWNx using command line/screen |
|
|
Hi all,
We are planning to implement NWNx on our server (late decision, I know!). I've run in to a minor issue however - likely induced by my very meager ability with linux - that I'm hoping you would help me with. I've searched the forums for an answer but to no avail, but please bear with me if it has been asked before.
What I'm looking to do is to run NWNx through a regular shell script, since we already have a process watchdog in place that we intend to continue utilizing if possible. Since our watchdog also handles running server updates (our module filename changes accordingly), we however need to be able to handle command line options dynamically. So my first question is simply:
Would it work to edit the nwnstartup.sh script and replace the:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
./nwserver \
-publicserver 1 \
-servername YourServerHere \
-dmpassword yourpw \
-oneparty 0 \
-pvp 0 \
-difficulty 2 \
-elc 1 \
-reloadwhenempty 0 \
-module "YourModuleHere" \
-maxclients 32 \
-servervault 1 \
-maxlevel 40 \
-gametype 0 \
-autosaveinterval 0 \
"$@" |
with just:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
./nwserver $@ |
So that we pass all the command line options to our calling of the nwnstartup.sh script in our own shell script.
... and is there a reason it's "$@" and not $@ in nwnstartup.sh?
Second, is it possible to edit the nwnstartup.sh script to run through a screen so it becomes:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
screen ./nwserver $@ |
All help would be very much appreciated. I know some of it is related more to how linux work rather than NWNx, but I hope you can bear with me on that too. |
|
Back to top |
|
|
Lokey
Joined: 02 Jan 2005 Posts: 158
|
Posted: Mon Aug 15, 2011 23:48 Post subject: |
|
|
Yah, I prefer to put that info in the ini files too.
The '$@' in delimiters of some type because of how something works. Also you'd want to do your log handling there or well somewhere. They add up fast. Also consider acaos' netoverride, fewer crash bugs, the better.
Otherwise, we just run something like
Code: | while [ true ]; do ./nwnstartup.sh; sleep 5; done |
in a screen session. Server name you might want to pass into the nwserver call, I think there's situations where it won't take properly from ini.
So anyway, I'm not sure you can invoke screen that way. You can mess with some script like echo $@; echo '$@'; and feed it some flags and see what happens. _________________ Neversummer PW NWNx powered mayhem |
|
Back to top |
|
|
Paul R
Joined: 17 Apr 2009 Posts: 42
|
Posted: Thu Aug 18, 2011 0:07 Post subject: Re: Running NWNx using command line/screen |
|
|
Zarathustra217 wrote: | Would it work to edit the nwnstartup.sh script and replace the:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
./nwserver \
-publicserver 1 \
-servername YourServerHere \
-dmpassword yourpw \
-oneparty 0 \
-pvp 0 \
-difficulty 2 \
-elc 1 \
-reloadwhenempty 0 \
-module "YourModuleHere" \
-maxclients 32 \
-servervault 1 \
-maxlevel 40 \
-gametype 0 \
-autosaveinterval 0 \
"$@" |
with just:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
./nwserver $@ |
So that we pass all the command line options to our calling of the nwnstartup.sh script in our own shell script.
... and is there a reason it's "$@" and not $@ in nwnstartup.sh?
|
Yes you can and you may need to keep that as having double quotes around the variable, it affects the arguments as they are expanded out and if the quotes you supply around the arguments are also quoted.
This is from the bash man page and explains the difference between the $@ and $* shell variables and what happens if you quote them in the script.
Code: | * Expands to the positional parameters, starting from one. When the expansion occurs within double
quotes, it expands to a single word with the value of each parameter separated by the first character of
the IFS special variable. That is, "$*" is equivalent to "$1c$2c...", where c is the first character of
the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is
null, the parameters are joined without intervening separators.
@ Expands to the positional parameters, starting from one. When the expansion occurs within double
quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the
double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the
beginning part of the original word, and the expansion of the last parameter is joined with the last
part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing
(i.e., they are removed). |
Quote: | Second, is it possible to edit the nwnstartup.sh script to run through a screen so it becomes:
Code: | #!/bin/sh
export LD_PRELOAD=./nwnx2.so
screen ./nwserver $@ |
|
You can use screen but you will need to use some more options to it, it's not something I use personally but there are some posts on here with some examples. You will get an error if you export the LD_PRELOAD var as you have it there because it will affect every external command after it has been set, in other words when the screen command is executed the dynamic linker will now try and attach the nwnx2 shared library to that process as well which at best is not going to work.
So as Lokey mentions you may need to execute the script as screen session rather than using screen in the script.
As you said you were new to Linux I just want to check you know what it is for and actually need to use it as it can complicate things slightly
The screen command executes the command as a separate process in the background in something a bit like a virtual terminal, you can connect to the the input and output streams later on using another screen command so you can use the nwserver console commands like "say".
Paul _________________ oops |
|
Back to top |
|
|
Zarathustra217
Joined: 15 Aug 2011 Posts: 5
|
Posted: Thu Aug 18, 2011 9:14 Post subject: |
|
|
Thanks a lot for the help, both.
What we ended up doing was running the nwnstartup.sh script in a screen rather than using screen within it. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|