I'm trying to write a simple batch script to test my Scala program. The script should be something like this:
#!/bin/bash
scala ./build/classes/MyClass "../../res/some_file.txt"
This returns:
Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: ./build/classes/MyClass
If I'm in the classes directory running:
#!/bin/bash
scala MyClass "../../res/some_file.txt"
works as expected.
What am I doing wrong here?
-Lee
You cannot pass the file name of a class -- you have to pass the class name, and it has to be in the classpath. So, instead, try this:
#!/bin/bash
scala -cp ./build/classes MyClass "../../res/some_file.txt"
Related
This is my first time working on a spring batch project. So I need to know how to pass arguments to the main class in a .sh file. The project is currently working and .sh file has a command line like this:
java -Xmx2048M -jar somebatch-SNAPSHOT.jar applicationContext.xml
And I want to pass arguments by changing this command. the project runs all jobs at the main class so job names are not specified in the command. What I want to do is pass arguments so I can select which jobs will run. Something like this:
java -Xmx2048M -jar somebatch-SNAPSHOT.jar --argument 1 applicationContext.xml
I don't need to pass the arguments to the jobParameters like java -jar somejar.jar somejob value=1 as shown in some examples. I only need a value in the main class.
Any help is appreciated.
I don't need to pass the arguments to the jobParameters like java -jar somejar.jar somejob value=1 as shown in some examples. I only need a value in the main class.
In this case, you can pass parameters on the command line with -Dparam=value and then get them in your main class using System.getProperty("param").
I have a shell script that should run the pentaho transforamtion job but it fails with the following error:
/data/data-integration/spoon.sh: 1: /data/data-integration/spoon.sh: ldconfig: not found
Here's the shell script which sits in:
/home/tureprw01/
and the script:
#!/bin/sh
NOW=$(date +"%Y%m%d_%H%M%S")
/data/data-integration/./pan.sh -file=/data/reporting_scripts/op/PL_Op.ExtlDC.kjb >> /home/tureprw01/logs/PL_Op.ExtDC/$NOW.log
I'm completely green in terms of Java but need to make it work somehow
Using command line executions for Pan / Kitchen is simple, This Documentation should help you create the Batch/SH command and make it work.
Though i see you are using variable creation on the command line, personally i do not know if the Batch/SH variable is passed down correctly to the PDI parameters, you'd have to test that yourself, or use this variable definition within the PDI structure, not as a named parameter.
use this :
!/bin/sh
NOW=$(date +"%Y%m%d_%H%M%S")
cd /data/reporting_scripts/op/
/data/data-integration/spoon.sh -main org.pentaho.di.pan.Pan -initialDir /data/data-integration -file=/data/reporting_scripts/op/PL_Op.ExtlDC.kjb
#!/bin/bash
# use for jobs if you want to run transform change :
# "org.pentaho.di.kitchen.Kitchen" to "org.pentaho.di.pan.Pan" and insert ktr file
export PENTAHO_JAVA_HOME=/root/app/jdk1.8.0_91
export JAVA_HOME=/root/app/jdk1.8.0_91
cd /{kjb path}/;
/{spoon path}/spoon.sh -main org.pentaho.di.kitchen.Kitchen -initialDir /{kjb path}//{kjb file}.kjb -repo=//{kjb path}/{resource file}.xml -logfile=/{log file}.log -dir=/{kjb path}
The requirement is to call the weblogic function:
connect([username, password], [url], [adminServerName])
inside a python file which is again called inside a shellscript as follows:
Inside shell script:
python myweblogiccall.py
I am getting an exception like
unknown name connect
when called inside the python file
Although WLST scripts have py or jy extension they are different than Python scripts in the way they function. Any WLST script needs an environment to be setup before coming up into action. There are 2 ways you can run your WLST scripts. I am assuming that you only need help to run WLST and a working WLST script is handy already.
Source setDomainEnv.sh and call WLST script as below.
source <Domain_HOME>/bin/setDomainEnv.sh
java weblogic.WLST <Script_HOME>/script.py
Run the WLST script through wlst.sh
./<Oracle_HOME>/Oracle_common/bin/wlst.sh <Script_HOME>/script.py
I am having a spring batch application, that is invoked through the command line. I would want to put that invocation in a shell script, so that I can run a script rather than the entire command.
For example, my invocation looks like:
java -jar run=1
The problem is for each run, the job parameter needs to be incremented. Is there a way through which i can achieve that in a shell script?
Thanks
You need an incrementer for this as usual.
<bean id="simpleIncrementer"
class="org.springframework.batch.core.launch.support.RunIdIncrementer"/>
<job id="myJob" incrementer="simpleIncrementer">
</job>
The trick for this incrementer to work with CommandLineJobRunner is adding the -next parameter when running the task.
-next: (optional) to start the next in a sequence according to the JobParametersIncrementer in the Job
Something like this:
java –jar myjob.jar jobs/myjob.xml myjob -next
You can do it n times (in a terminal) using a for loop this way:
for i in {1..10}; do java -jar run=$i; done
I have a groovy script and I need to call a ruby script.
I would like to pass arguments to Ruby script and would like to capture the output from Ruby script to use it in Groovy Script. Can somebody suggest how I can do this? I tried Process.execute(). It works for other dos commands but not for cmd /c ruby test.rb.
Since a ruby file isn't a batch file you don't need to use cmd to execute it. You could do
Process.execute("ruby.exe test.rb")
Assuming ruby.exe is on your path. Another option depending on your requirements may be to use JRuby which will allow you to run ruby code on the JVm and integrate nicely with Groovy.