LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with my run.sh (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-my-run-sh-832651/)

Dylannnnn 09-16-2010 03:10 PM

Problem with my run.sh
 
Ok, im quite new to linux but have an "ok" knowledge of it.

I am trying to convert my batch file into a .sh file and i think i have it perfect but it just will not work, so obviously not perfect.

This is the code for my batch file.

Code:

@echo off
title Server
java -Xmx800m -cp bin;deps/poi.jar;deps/mysql.jar;deps/mina.jar;deps/slf4j.jar;deps/slf4j-nop.jar;deps/jython.jar;log4j-1.2.15.jar; server.Server
pause

This works perfectly on my own computer without any problems. I want to host this on my Linux VPS (CentOS 5) and need it to be converted into run.sh.

This is the code for my run.sh.

Code:

#!/bin/sh
java -Xmx800m -cp bin;deps\poi.jar;deps\mysql.jar;deps\mina.jar;deps\slf4j.jar;deps\slf4j-nop.jar;deps\jython.jar;log4j-1.2.15.jar; server.Server
sleep

As I have said I don't think anything is wrong with it but obviously there is as it will not run the server. If someone could help me with this it would be very much appreciated.

AlucardZero 09-16-2010 04:06 PM

Well what messages do you get when it runs on the server?

Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.

Dark_Helmet 09-16-2010 05:03 PM

Ok, I've got to ask to cover all the bases. You have execute/run permissions on the script, right?

Secondly, I know nothing about executing java from the command line, but aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.

Dylannnnn 09-17-2010 10:41 AM

this is the error i get when i change the run.sh and edited the "\" to "/"

This is my run.sh file
Code:

#!/bin/sh
java -Xmx800m -cp bin;deps\poi.jar;deps\mysql.jar;deps\mina.jar;deps\slf4j.jar;deps\slf4j-nop.jar;deps\jython.jar;log4j-1.2.15.jar; server.Server
sleep

This is the error i get with it.
Code:

run.sh: line 2: deps/poi.jar: Permission denied
run.sh: line 2: deps/mysql.jar: Permission denied
run.sh: line 2: deps/mina.jar: Permission denied
run.sh: line 2: deps/slf4j.jar: Permission denied
run.sh: line 2: deps/slf4j-nop.jar: Permission denied
run.sh: line 2: deps/jython.jar: Permission denied
run.sh: line 2: log4j-1.2.15.jar: command not found
: command not found
: command not foundver.Server
: command not foundep

this is realllllly annoying me now.

I have chmod +x run.sh

AlucardZero 09-17-2010 11:31 AM

So, yes. Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.

Aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.

Dylannnnn 09-17-2010 11:52 AM

Quote:

Originally Posted by AlucardZero (Post 4100803)
So, yes. Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.

Aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.

Ok this is now my run.sh file.

Code:

#!/bin/sh
java -Xmx800m -cp bin:deps/poi.jar:deps/mysql.jar:deps/mina.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar server.Server
read 10s

Is this right?

I get an error with this.

Code:


Exception in thread "main" java.lang.NoClassDefFoundError: server/Server
Caused by: java.lang.ClassNotFoundException: server.Server
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
. Program will exit.ain class: server.Server


Dylannnnn 09-17-2010 06:23 PM

still looking for help <3

MTK358 09-17-2010 07:45 PM

Note that the file doesn't have to end with .sh, Linux has no OS or filesystem-level concept of file extensions.

Dark_Helmet 09-18-2010 12:21 AM

Quote:

Originally Posted by Dylannnnn
Code:

Caused by: java.lang.ClassNotFoundException: server.Server

Your command ends with "server.Server"--which indicates what object serves as the application's starting point. The error above seems to be saying that java can't find an object defined by that name.

So, we really can't help much other than to say the problem is likely in one of two places:
1. The command line is specifying the starting class incorrectly. This might be a result of the fact that Linux is case-sensitive for names, whereas my experience with Windows (which is somewhat dated now) indicates that Windows is NOT case-senstive. Verify how the class is defined in the code you're trying to start.

2. There is one (or more) additional files that are not being loaded/included properly. Double-check your paths for spelling mistakes and double-check your file lists to make sure all needed files are included on the command line.

Dylannnnn 09-18-2010 06:30 AM

Quote:

Originally Posted by Dark_Helmet (Post 4101346)
Your command ends with "server.Server"--which indicates what object serves as the application's starting point. The error above seems to be saying that java can't find an object defined by that name.

So, we really can't help much other than to say the problem is likely in one of two places:
1. The command line is specifying the starting class incorrectly. This might be a result of the fact that Linux is case-sensitive for names, whereas my experience with Windows (which is somewhat dated now) indicates that Windows is NOT case-senstive. Verify how the class is defined in the code you're trying to start.

2. There is one (or more) additional files that are not being loaded/included properly. Double-check your paths for spelling mistakes and double-check your file lists to make sure all needed files are included on the command line.

This is my file layout:

The file server has bin src deps data run.sh

the bin file goes like this. bin>server>and the Server.class file is in here.

in the deps folder all the .jar files are in there.

I really do not know why it is not working.. please help :L


All times are GMT -5. The time now is 07:45 AM.