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.
Related
I run a Minecraft Java Modded server on my computer. The only way to run it is to use PowerShell and change the directory to where the jar file is located, then type "java -jar server.jar" for example. How can I make a batch file to do this so that all I have to do is click on the batch file every time I want to run the server?
Create a shortcut to powershell.exe -file "c:\path\to\file\launcher.ps1".
The PowerShell file (launcher.ps1) should contain these lines:
Set-Location "C:\Minecraftfolder\jarfiles"
java -jar server.jar
i am trying to run Pact broker can i deploy tool with paramaters which is working fine locally but when i add the build step in TeamCity it is throwing below error
Start-Process : This command cannot be run due to the error: The
system cannot find the file specified.
when i run the same powershell script locally, it is working fine .
powershell script:
CanIDeploy.bat code is
Note: the reason i am calling pact-broker.bat from power shell script is, unable to run bat file from Teamcity , that is the reason created powershell script which internally calls pact broker bat file.
any help is appreciated
I see that you use relative path, but what about the working directory? I see a different path in the error message vs what you show where the file is.
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
I have scrip contain command line:
set dir=%1
cd %dir%
test.bat
echo successful
When run this script, file test.bat (this file run phpunit) run complete then this script don't run command line echo successful.
So, how to try run to eof script.
Use call test.bat.
When you try running a batch file from another batch like in your question control does not pass back to your calling batch.
Side note: I'd usually use pushd/popd for going into directories from batch files. At least I prefer when a batch file doesn't have a side-effect on the shell I'm working on (similar rationale for setlocal). Also this solves the problem when you pass a directory on another drive (although you could do cd /d in that case.
TASK TO BE ACCOMPLISHED:
To schedule a perl script which is executed on a specific time / day in a week
THINGS I HAVE DONE:
In a schedule Tasks, I have created a new Task by which the Task will call a batch file with below contents
cd "DRIVE\FOLDER\Hummingbird\Connectivity\14.00\Exceed\"
ABCD.xs
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
THINGS NOT WORKING FOR ME / CAUSING THE ISSUE:
Wen I run the scheduler, the prompt opens up the ABCD.xs exceed file window seperately file but the below commands are executed in the command pronpt itself
EXPECTED OUTPUT:
I want the commands
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
to be executed in the exceed window
Any kind of solution wud be great
Thanks in advance.
Haresh
Sounds like you need to start getting into either SendKey stuff (Win32 packages) or else look into writing Exceed/Hummingbird scripts and just executing those.
Some other things to look into... does the remote server have a telnet or ssh server running? Or are there other methods of executing code on the remote server?
For example, my work's mainframe is accessed via a Hummingbird terminal emulator, but I can also telnet to the mainframe and execute commands as well as FTP batch job directly into the JES spool. So when I execute things on the mainframe by way of my PC (Perl scripts, etc.), I don't even fool with Hummingbird.
Good luck...