How to run the job within springbatchadmin.war from command line?
I used the following command in command prompt to run the job.
D:\apache-tomcat-6.0.35\webapps\springbatchadmin>java -classpath "lib\*;src" com.companyname.batch.BatchLauncher job1Cfg job1
But I got the error and I cannot run the job.
Please give me right directions.
If you are using tomcat for deploying the admin, then the .war file should have deployed itself into a folder as soon as you start the server once. Now you can trace to the location of the xml files inside that folder, and execute jobs from command-line.
eg: in my case, the xml files are in the folder,
tomcat\webapps\my_project_war\WEB-INF\classes\springbatch
So just in case you want to run a job (say 'abcJob') inside an xml, say 'xyz.xml',
use the command,
java org.springframework.batch.core.launch.support.CommandLineJobRunner "tomcat\webapps\my_project_war\WEB-INF\classes\springbatch\xyz.xml" "abcJob" parameter1=value1 etc
While running from command-line, you can also set the classpath variable to some constant location, so that you can run all relative jobs with reference to that location. (in my case it is'tomcat\webapps\my_project_war\WEB-INF\classes')
So I would use the command,
java org.springframework.batch.core.launch.support.CommandLineJobRunner "classpath*:springbatch/xyz.xml" "abcJob" parameter1=value1
Related
I'm trying to execute sh-file from resources.
Executed file is located at the root of resources: src/main/resources/hiveCommand.sh
import sys.process._
"./hiveCommand.sh" !!
But receive IOException: not such file or directory
What am I doing wrong?
Scala's Process integration does not know how to handle shell scripts. It can only start programs. To run a shell script you need start a shell (e.g. bash) and give it the file to run as an argument.
There is a complication however. Since the script is a resource (located at src/main/resources/hiveCommand.sh during compile time), it is located in a jar at run time.
So in short:
First extract the shell script (use getClass.getResourceAsStream("/hiveCommand.sh") to read the resource) and store it on disk.
Then start with something like:
"bash /tmp/hiveCommand.sh".!!
I have abc.jar file to deploy and run in remote machine.
I have transferred the file using jenkins, now what I have done is, call a a.bat batch file on remote machine using psexec in Execute Windows Batch Command.
a.bat executes the abc.jar
When the jar begins execution, the command prompt texts are stored in a file.
using java -jar abc.jar >> a.log 2>&1
Now what I want is to display the a.log contents in the jenkins console when the jar file is being executed
(the file is continuously being written and I want to show it in jenkins console as it is being written)
I have tried to do it using parallel processing by calling start twice, one for calling batch file, another using type for displaying.
But when I use start I get Process leaked file descriptor .
Is there any other way I can achieve this. Be it calling powershell or scheduled task in jenkins.
You need to look for tee equivalents in windows , there are few like GNU utilities for Win32, however if you have cygwin you can still use tee which will easy the prcoess.
Now the wuestion arises how to run my jar file on cygwin from jenkins ?
you can still use execute windows[batch] shell. and add cygwin installation path to the PATH variable and start using linux command like a BOSS.
or you can use powershell tee in built command from batch.
I am able to run a .exe from the command line, but when I try and run it using the Task Scheduler, I get the error "The system cannot find the path specified. (0x80070003)"
I am running this on a server, so I have tried mapping the drive and also using the full path. Both of these methods work using the command line.
This is how I have the Program/script set to run:
D:\scripts\lilt\NewFile.exe \err00\root\LILT\ILL\ \pcc02\Inter\I040\ILL\Inbox\"
What do I need to do, to get this to run on the scheduler? Thanks!
I figured it out. I had to use the "Add arguments (optional)" section to indicate the drives and not put it in the Action line. (As some history, I'm moving this task from a PC to a server, and the PC had it all in the one line, as well, when running from cmd on the server, I could execute it successfully on one line, but it behaves differently once you make it a task apparently.
So this went in "Action":
D:\scripts\lilt\NewFile.exe
And this went in Add arguments (optional):
\err00\root\LILT\ILL \pcc02\Inter\I040\ILL\Inbox
I have changed the shell key in windows registry to gain custom shell (Kiosk usage):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon]
I set shell key to a batch file which runs two applications as below:
start "myFirstAppTitle" "myAppPath\myApp1.exe"
start "mySecondAppTitle" "myAppPath\myApp2.exe"
Each application runs but the second application which needs some files to be excuted throws an error which says could not find dependency files. whereas the dependency files are adjoining to the exe file and the mentioned app works fine, when starts from startup.
Meanwhile when i run the batch file manually it rusn fine.
I added the PATH command to the batch file but it did't work too.
Change the batch file to this:
set PATH=%PATH%;C:\MyAppPath
start "myFirstAppTitle" "myApp1.exe"
start "mySecondAppTitle" "myApp2.exe"
If you start executables without an absolute path, the path is relative to the current working directory. Also, when you specify an executable with a relative path, %PATH% is not searched for a matching subfolder with a matching executable.
Since the script worked when you manually started it, your working directory probably was C:\. However, when run at logon as a replacement shell, the working directory is most likely "%SystemRoot%\system32".
The problem solved strangely, i removed the title parameter of start command and it worked. In fact i used start command this fashion:
set PATH=%PATH%;C:\MyAppPath
start myapp.exe
start myapp2.exe
I'm executing this code:
p = subprocess.Popen(['/path/to/my/script.sh','--flag'] , stdin=subprocess.PIPE)
p.communicate(input='Y')
p.wait()
It works when executing it on the shell using "python scriptName.py",
BUT when executing using PyDev in Eclipse, it fails, the reason:
/path/to/my/script.sh: line 111: service: command not found
This bash script "script.sh" contains the following command which causes the error:
service mysqld restart
So "service" is not recognized when running the .sh script from the context of PyDev.
I guess it has to do with some ENV VAR configurations, couldn't find how to do it.
BTW - Using "shell=True" when calling subprocess.Popen didn't solve it.
service usually is located in /usr/sbin, and that this directory isn't on the PATH. As this usually contains administrative binaries and scripts which arn't designed to be run by everyone (only by admins/root), the sbin directories arn't always added to the PATH by default.
To check this, try to print PATH in your script (or add an env command).
To fix it, you could either
set the PATH in your python script using os.setenv
pass an env dict containing the correct PATH to Popen
set the PATH in your shellscript
use the full path in your shellscript
set the PATH in eclipse