LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   CentOS .sh server help (https://www.linuxquestions.org/questions/linux-newbie-8/centos-sh-server-help-4175427033/)

stevnnnn 09-13-2012 06:08 AM

CentOS .sh server help
 
Hey, I'm quite new to CentOS/linux and I'm trying to run a server. I've installed all the required things, and the server was originally meant to be ran on windows, hence I had problems making it compatible with CentOS. The problem I'm having is that I'm not sure if my .sh is in proper format for it to launch, because it doesn't show any error nor any signs of success so I'm not too sure if it's working. Any ways, this is what happens when I launch it from terminal.
Code:

[root@xx lithium]# sh dump-items.sh
[root@xx lithium]# sh dump-mobskills.sh
dump-mobskills.sh: line 2: export: `-server': not a valid identifier
dump-mobskills.sh: line 2: export: `-Dnet.sf.odinms.wzpath=/wz': not a valid identifier
dump-mobskills.sh: line 2: export: `tools.wztosql.DumpMobSkills': not a valid identifier
[root@xx lithium]# sh dump-quests.sh
[root@xx lithium]# sh launch.sh

I've changed the dump-mobskills.sh to export CLASSPATH instead of set CLASSPATH just to test it. Here are the .sh files.

dump-items.sh
Code:

#!/bin/sh
set CLASSPATH=dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar java -server -Dnet.sf.odinms.wzpath=/wz tools.wztosql.DumpItems

dump-mobskills.sh
Code:

#!/bin/sh
export CLASSPATH=/dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar:bcprov-jdk16-145.jar java -server -Dnet.sf.odinms.wzpath=/wz tools.wztosql.DumpMobSkills

dump-quests.sh
Code:

#!/bin/sh
set CLASSPATH=/dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar:bcprov-jdk16-145.jar java -server -Dnet.sf.odinms.wzpath=/wz tools.wztosql.DumpQuests

launcher.sh

Code:

#!/bin/sh
set CLASSPATH=/dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar java -server -Dnet.sf.odinms.wzpath=/wz server.Start

When I run it in gui, the run in terminal opens and closes right away, whilst for run it doesn't show up at all. I can't think or find anything that seems to be wrong.

-Steven

chrism01 09-13-2012 08:28 PM

1. when writing a shell script, use multiple lines; easier to read/debug and it runs just as fast.

2. you can only export values down to sub-shells created in the parent; all of yours are running at the same level, so you can't export vars between them like that.

3. *nix is a quiet system; a cmd generally only outputs something if a) an error occurred or b) the cmd is supposed to return some data eg the ls cmd.
Otherwise its quiet.
You can check the success status using the shell special internal var '$?'
http://tldp.org/LDP/abs/html/internalvariables.html

4. Try these links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

stevnnnn 09-14-2012 06:27 AM

Hey, thanks for the reply but I am not quite sure what you just said, again I am new to CentOS/linux and this is my first time using it.
For 3. , is there a way to make it show what's on the .sh's instead of it running quiet?

-Steven

unSpawn 09-14-2012 08:18 AM

Quote:

Originally Posted by stevnnnn (Post 4779279)
the server was originally meant to be ran on windows, hence I had problems making it compatible with CentOS.

It's Java so that shouldn't matter, should it?


Quote:

Originally Posted by stevnnnn (Post 4779279)
Code:

#!/bin/sh
set CLASSPATH=/dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar java -server -Dnet.sf.odinms.wzpath=/wz server.Start

When I run it in gui, the run in terminal opens and closes right away, whilst for run it doesn't show up at all. I can't think or find anything that seems to be wrong.

The original scripts set the CLASSPATH as
Code:

export CLASSPATH=".:dist/(..):dist/
meaning "in this directory (aka $PWD) or the "dist" subdirectory", so not "/dist". Now it could be a lack of line ending conversion (see 'man dos2unix') but then the original launch script runs the lines over several lines, first setting up the requisite CLASSPATH and then executing java. If we take for instance your "dump-items.sh" it should read:
Code:

#!/bin/sh
export CLASSPATH=".:dist/booms.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar"
java -server -Dnet.sf.odinms.wzpath=/wz tools.wztosql.DumpItems
exit 0

* Please read the relevant documentation and ensure you understand if running a private server is in violation of the license(s).

stevnnnn 09-14-2012 09:13 AM

Thank you very much, sorry for being a bit clueless but I did understand and have learnt from this.

And I completely understand the consequences of hosting a private server.

Steven


All times are GMT -5. The time now is 06:21 AM.