Error while running my run.sh (linux) - linux

I recently encountered this error while running my run.sh. I am trying to run a Runescape Private Server on my linux VPS; this is a large error. Please assist me, I dont know what other details to add.
Error:
jacob#ace:~/Server/source$ sh run.sh
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
run.sh: 1: run.sh: deps/poi.jar: Permission denied
run.sh: 1: run.sh: deps/mysql.jar: Permission denied
run.sh: 1: run.sh: deps/mina.jar: Permission denied
run.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

Add #!/bin/sh -vx as the first line of your run.sh script (to get a trace of he shell).
You probably need to quote the classpath, i.e.
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
I strongly suggest to take a few hours to read the advanced bash scripting guide.

You must change ; to : of that i'm 100% sure!
Maybe that will fix your errors.
revision 718 RSPS runner(maybe useful for others searching this):
#!/bin/bash
nohup java -cp bin:lib/*: com.rs.Launcher true true false

Related

How to use Sass with NetBeans on Linux / macOS

I used to be able to install and use Sass with NetBeans 8 as described in the top answer on How to use SASS with Netbeans 8.0.1
Now, with the current version of Sass (1.14.1), installing is different. Basically just download and untar. That's done and I've pointed NetBeans to the correct location. But this current version of Sass won't run correctly from NetBeans:
"/opt/dart-sass/sass" "--cache-location"
"/home/jasper/.cache/netbeans/8.2/sass-compiler"
"path_to_my.scss" "path_to_my.css"
Could not find an option named "cache-location".
This error is also covered by Sass output error in Netbeans 8.2 where they are using Windows.
I tried to add the cache location parameter (similar to the solution for Windows) to this line in the sass file:
exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "$#"
but I could not get it working (same error keeps appearing).
Anybody any ideas on how to get Sass 1.14.1 working from NetBeans 8.2 on Linux (Ubuntu)?
The issue is that --cache-location is no longer supported and should be removed. All of the original parameters are used by "$#". To remove the first two parameters, you should be able to use "${#:3}" (see Process all arguments except the first one (in a bash script)), but somehow that resulted into a "Bad substitution" error for me. So I opted to use shift 2 to remove them:
#!/bin/sh
# Copyright 2016 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
# This script drives the standalone Sass package, which bundles together a Dart
# executable and a snapshot of Sass. It can be created with `pub run grinder
# package`.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 2
exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "${#}"
Make sure to keep the original file and create a copy to only be used with NetBeans and make the change there.
macOS (Home Brew)
If you are looking for the Dart Sass install location (after installing it with Home Brew), it is located here:
/usr/local/Cellar/sass/{version}/bin
macOS (node.js)
When using node.js, you will run into the "env: node: No such file or directory" issue.
To work around that I created (make sure you make it executable (chmod a+x)):
/usr/local/lib/node_modules/sass/sass_nb.sh
and added:
#!/bin/zsh
export PATH="$PATH:"/usr/local/bin/
shift 3
sass ${#}
NetBeans 11+
On NetBeans 11 and 12 I had to use shift 3 instead of shift 2.
My response is based heavily on Jasper de Vries'one:
It seems that Netbeans simply adds some additional parameters that are no longer supported by sass compiler.
In my case the complete command issued by Netbeans was:
"/home/alex/tools/dart-sass/sass" "--cache-location" "/home/alex/snap/netbeans/common/cache/12.0/sass-compiler" "--debug-info" "/home/alex/projects/alexgheorghiu.com/web/aaa.scss" "/home/alex/projects/alexgheorghiu.com/web/aaa.css"
So the first 3 parameters
"--cache-location" "/home/alex/snap/netbeans/common/cache/12.0/sass-compiler" "--debug-info"
must be "deleted" or ignored.
So you need to either alter the sass file or make a copy of it (safest way)
and add
shift 3
instruction.
So if you start from original version like:
#!/bin/sh
# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
exec "$path/src/dart" "$path/src/sass.snapshot" "$#"
You need to end up with something like:
#!/bin/sh
# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 3
exec "$path/src/dart" "$path/src/sass.snapshot" "$#"
An interesting aspect is that this bug is known by Netbeans developers (See: Could not find an option named "cache-location") but I was not able to achieve that because under my Xubuntu 18 the Netbeans is a "snap" and therefore it's netbeans.conf file is read only.
But in case you CAN modify that file it might be a cleaner solution.

Why the jar file cannot be find in cygwin?

I am new to sygwin, so I am probably doing something wrong.
Here is my shell script:
!/bin/sh
set [-x]
export myInstallDirectory='/cygdrive/c/cygwin64/usr/uTrace_ServerMachine'
echo "myInstallDirectory=" $myInstallDirectory
export JAVA_HOME=/cygdrive/c/Java_JDK_SE_8_u77_64_bit
echo "JAVA_HOME = " $JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
echo "PATH =" $PATH
export CLASSPATH=$myInstallDirectory/bin/UtraceServer.jar:$CLASSPATH
echo "CLASSPATH=" $CLASSPATH
java -jar UtraceServer.jar
set [+x]
Here is what the log shows:
myInstallDirectory= /cygdrive/c/cygwin64/usr/uTrace_ServerMachine
JAVA_HOME = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
PATH = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
/bin:/usr/local/bin:/usr/bin:/cygdrive/c/windows/system32:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/WINDOWS:/cygdrive/c/WinZip/WINZIP/WINZIP32.EXE:/cygdrive/c/Java_JDK_SE_8_u77_64_bit/bin:/cygdrive/c/Java_JDK_SE_8_u77_64_bit/lib/tools.jar:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/bin:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/glassfish/bin:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/glassfish/lib/javaee.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbynet.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbytools.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbyoptionaltools.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/test/jakarta-oro-2.0.8.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/test/derbyTesting.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbyrun.jar:/cygdrive/c/IBM/DB2_EX~1/java/db2java.zip:/cygdrive/c/IBM/DB2_EX~1/java/db2jcc.jar:/cygdrive/c/IBM/DB2_EX~1/java/sqlj.zip:/cygdrive/c/IBM/DB2_EX~1/java/db2jcc_license_cu.jar:/cygdrive/c/IBM/DB2_EX~1/bin:/cygdrive/c/IBM/DB2_EX~1/java/common.jar:/cygdrive/c/ORACLE/NetBeans 8.1/java/maven/bin:/cygdrive/c/Program Files (x86)/Skype/Phone:/cygdrive/c/Cygwin/bin:/cygdrive/c/Program Files/Microsoft Network Monitor 3:/cygdrive/c/My_Software_Development/Client_Monitoring/Client_Scripts
CLASSPATH= /cygdrive/c/cygwin64/usr/uTrace_ServerMachine
/bin/UtraceServer.jar:.;C:\Java_JDK_SE_8_u77_64_bit\lib\tools.jar;C:\Java_EE_SDK_7_u2\glassfish4\glassfish\lib\javaee.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbynet.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbytools.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbyoptionaltools.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\test\jakarta-oro-2.0.8.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\test\derbyTesting.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbyrun.jar;C:\IBM\DB2_EX~1\java\db2java.zip;C:\IBM\DB2_EX~1\java\db2jcc.jar;C:\IBM\DB2_EX~1\java\sqlj.zip;C:\IBM\DB2_EX~1\java\db2jcc_license_cu.jar;C:\IBM\DB2_EX~1\bin;C:\IBM\DB2_EX~1\java\common.jar
Error: Unable to access jarfile UtraceServer.jar
The jarfile UtraceServer.jar is located in /cygdrive/c/cygwin64/usr/uTrace_ServerMachine/bin/UtraceServer.jar
and as you can see it is in the CLASSPATH.
Appreciate any help.
Java is not a Cygwin application so it can not understand its
PATH nor the cygdrive suffix.
JAVA_HOME = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
PATH = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
As explained in How to run Java from Cygwin, you can use Cygwin paths in your script, but just before you call Java, you should convert them to Windows paths, for instance with cygpath -p:
!/bin/sh -x
export myInstallDirectory='/cygdrive/c/cygwin64/usr/uTrace_ServerMachine'
echo "myInstallDirectory = $myInstallDirectory"
export CLASSPATH="$myInstallDirectory/bin/UtraceServer.jar:$CLASSPATH"
echo "CLASSPATH = $CLASSPATH"
CLASSPATH="$(cygpath -pw "$CLASSPATH")"
echo "CLASSPATH (Windows) = $CLASSPATH"
java -jar UtraceServer.jar
(I've omitted the other paths from the script, because Java is clearly found.)
cygpath can (among others) convert a single path between POSIX and and different Windows formats, e.g. -w converts a path to a Windows path. With the addition of -p it treats its argument as a path list (separated by : for POSIX, by ; for Windows). See cygpath --help for the full info.
Important: when you use this in scripts, it is recommended always to use double quotes (as in the script above). Doing this consistently considerably reduces the risks for issues caused by (e.g.) spaces in path names.

Cmake add command line argument to binary

I create a binary myBinary via cmake/CMakeLists.txt.
I would like to "include" default options on my binary.
In other words, I want my binary to be called with myBinary --option myopt even when I just run ./myBinary
How can I do that?
CMake does not have built-in support for you you want to do.
One solution is to do as #Youka said - change the source code of your program.
Another solution that I have used sometimes is to autogenerate a script that executes an executable:
# Create startup script
MACRO(GEN_START_SCRIPT binName)
# Generate content
SET(fileContent
"#!/bin/bash\n"
"\n"
"# This startup script is auto generated - do not modify!\n"
"\n"
"${binName} -a 23 -b 34 -c 976\n"
"\n"
)
# Write to file
SET(fileName ${CMAKE_CURRENT_BINARY_DIR}/${binName}.sh)
FILE(WRITE ${fileName} ${fileContent})
ENDMACRO()
Then call the macro after defining your executable:
ADD_EXECUTABLE(myBinary file1.c file.2)
GEN_START_SCRIPT(myBinary)
You can of course add other stuff to the script, like environment variables etc.
If you're in control of the sources and you want different default behavior... change the sources!
This is in no way a build system issue (CMake or otherwise).

How can I write own cloud-config in cloud-init?

cloud-init is powerful to inject user-data in to VM instance, and its existing module provides lots of possibility.
While to make it more easy to use, I want to define my own tag like coreos below, see detail in running coreos in openstack
#cloud-config
coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
discovery: https://discovery.etcd.io/<token>
# multi-region and multi-cloud deployments need to use $public_ipv4
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
So I could have something like below using my own defined tag/config myapp
#cloud-config
myapp:
admin: admin
database: 192.168.2.3
I am new to cloud-init, is it called module ? it is empty in document http://cloudinit.readthedocs.org/en/latest/topics/modules.html
Can you provide some information to describe how I can write my own module ?
You need to write a "cc" module in a suitable directory, and modify a few configurations. It is not terribly easy, but certainly doable (we use it a lot).
Find the directory for cloudconfig modules. On Amazon Linux, this is /usr/lib/python2.6/site-packages/cloudinit/config/, but the directory location differs in different cloud init versions and distributions. The easiest way to find this is to find a file named cc_mounts.py.
Add a new file there, in your case cc_myapp.py. Copy some existing script as a base to know what to write there. The important function is def handle(name,cfg,cloud,log,args): which is basically the entrypoint for your script.
Implement your logic. The cfg parameter has a python object which is the parsed YAML config file. So for your case you would do something like:
myapp = cfg.get('myapp')
admin = myapp.get('admin')
database = myapp.get('database')
Ensure your script gets called by cloud-init. If your distribution uses the standard cloud-init setup, just adding the file might work. Otherwise you might need to add it to /etc/cloud/cloud.cfg.d/defaults.cfg or directly to /etc/cloud/cloud.cfg. There are keys called cloud_init_modules, cloud_config_modules, etc. which correspond to different parts of the init process where you can get your script run. If this does not work straight out of the box, you'll probably have to do a bit of investigation to find out how the modules are called on your system. For example, Amazon Linux used to have a hardcoded list of modules inside the init.d script, ignoring any lists specified in configuration files.
Also note that by default your script will run only once per instance, meaning that rerunning cloud-init will not run your script again. You need to either mark the script as being per boot by setting frequency to always in the configuration file listing your module, or remove the marker file saying that the script has run, which lives somewhere under /var/lib/cloud like in /var/lib/cloud/instances/i-86ecc763/sem/config_mounts.
paste my note for you:
config: after installed cloud-init in VM,if u want to have root permission to access with passwd, do simple config below
modify /etc/cloud/cloud.cfg like below
users:
- defaults
disable_root:0
ssh_pwauth: 1
Note: ssh_pwauth: "it will modify PasswordAuthentication in sshd_config automatically, 1 means yes
Usage:
the behavior of cloud-init can configured using user data. user data can be filled by user during the start of instance (user data is limited to 16K).
Mainly there are several ways to do (tested):
user-data script
$ cat myscript.sh
#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt
when starting instance, add parameter --user-data myscript.sh, and the instance will run the script once during startup and only once.
cloud config syntax:
It is YAML-based, see http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/files/head:/doc/examples/
run script
#cloud-config
runcmd:
- [ ls, -l, / ]
- [ sh, -xc, "echo $(date) ': hello world!'" ]
- [ sh, -c, echo "=========hello world'=========" ]
- ls -l /root
- [ wget, "http://slashdot.org", -O, /tmp/index.html ]
change hostname, password
#cloud-config
chpasswd:
list: |
root:123456
expire: False
ssh_pwauth: True
hostname: test
include format
run url script, it will download URL script and execute them sequence, this can help to manage the scripts centrally.
#include
http://hostname/script1
http://hostname/scrpt2

Expected one of #, input, filter, output in logstash

I am trying to make logstash installation work by simply executing the command given in the documentation to echo back what ever typed.But that gives me the following error.
My command
C:\logstash-1.4.0\bin>logstash.bat agent -e 'input{stdin{}}output{stdout{}}'
And the error
Error: Expected one of #, input, filter, output at line 1, column 1 (byte 1) aft
er
You may be interested in the '--configtest' flag which you can
use to validate logstash's configuration before you choose
to restart a running system."
Please help.Thanks in advance!
I am testing with logstash-1.4.0 on linux with this tutorial.
I think it is possible a bug on this version.
For example, I test this command on both linux and window. Everything is ok on linux. But it will occur your error at window!!
bin>logstash agent -e 'input{stdin{}}output{stdout{}}'
For my recommendation, you can write your configuration in a file. For example, save input{stdin{}}output{stdout{}} to a file call "stdin.conf". Then when you start logstash, don't use -e flag, instead use -f and specific your configuration file.
bin>logstash agent -f stdin.conf
Hope this can help you.
Try without quotes
C:\logstash-1.4.0\bin>logstash.bat agent -e input{stdin{}}output{stdout{}}
I get this error when I run -e with --debug. I have to remove -e. Example:
GEM_HOME="/opt/logstash/vendor/bundle/jruby/1.9/" /usr/lib/jvm/java-1.6.0/bin/java -server -Xms765M -Xmx2297M -Djava.io.tmpdir=/opt/logstash/forwarder/tmp/ -Xmx2297M -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -jar /opt/logstash/forwarder/vendor/jar/jruby-complete-1.7.11.jar -I/opt/logstash/forwarder/lib /opt/logstash/forwarder/lib/logstash/runner.rb agent -f /opt/logstash/forwarder/etc/conf.d/ -l /opt/logstash/forwarder/log/logstash.log -w 1 --debug

Resources