Run jarfile on ftp without downloading - java

I have executable jar file which i have kept on my ftp.
I wanted to autoschedule it through linux server - cronjob.
I given the command :
java -jar filepath.jar
But when call goes to that file, it always asks for download, and after getting downloaded, it does not run automatically.
I want it to run automatically on the same server on which it is present (on ftp).
which command i can use for it??
Please help.

You could put something like this in your crontab :
ssh user#host 'java -jar filepath.jar'
and previously exchanging public keys between client and server so you won't be asked for the password

FTP is file transfer protocol. It cannot be used to execute programs. You have to use ssh, if that is possible.

Yes, use ssh to login into remote PC or server ,
That can be done using command "ssh username#IP Address of remote pc" on terminal.
By this way u can login in into remote pc and u will get the terminal of that PC inside your terminal.
Now u can browse the files in that PC and simply execute any file u want without downloading.

Related

Im trying to Write a java Program to connect to a remote server where my database is located and do a "mysqldump"

I am trying to connect to my database on a server and create a MySql dump using java, but it results in:
Runtime.getRuntime().exec(" mysqldump -h 10.10.104.1 -P 3XX6 -u xxxxxx -pXXXXX snappoint > backup.sql");
java.io.IOException: Cannot run program "mysqldump":
what am I doing wrong?
Are you sure mysqldump is installed locally?
I'll explain - Runtime.getRuntime().exec runs on your local machine. This means all code executed inside it will run on your machine, and not on any remote site you are connecting to.
So what it means is that every binary executed here must be installed on the machine running the code, and that is why you received this error.
So i figured it out
The problem was that Runtime.getruntime().exec //occurs on ur local machine so u need to install mysqldump on ur local machine and not on the server
Hopefully someone needs this someday

Local JNLP file not read for jenkins slave

I am trying to connect jenkins slave to the master.
We are allowed to have only one port (say 8888) open from the corporate firewall to talk to the master hosted on AWS. The port is being used for connecting to the jnlp process running on the master jenkins machine. Due to this reason we cannot download the slave-agent.jnlp file using http. I have manually downloaded the slave-agent.jnlp file and I am trying to give the following command to start the agent up.
java -jar slave.jar -jnlpUrl file:///oracle/app/jenkins/slave-agent.jnlp -secret 7f079707d5632d2db2501be73f1a6f5f6422b9c9fde806afd8fdd2000d5db123
I get the the following error
Failing to obtain file:/oracle/app/jenkins/slave-agent.jnlp?encrypt=true
java.io.IOException: file:/oracle/app/jenkins/slave-agent.jnlp?encrypt=true doesn't look like a JNLP file; content type was null
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:301)
at hudson.remoting.Launcher.run(Launcher.java:218)
at hudson.remoting.Launcher.main(Launcher.java:192)
Waiting 10 seconds before retry
I have tried this as well without any luck.
java -jar slave.jar -jnlpUrl file://localhost/oracle/app/jenkins/slave-agent.jnlp -secret 7f079707d5632d2db2501be73f1a6f5f6422b9c9fde806afd8fdd2000d5db123
The file is present at the location has read write permissions.
Any clue on why the java process is not able to read that file?
Answer by #gareth_bowles is wrong at least today, the url will work as a file url as well. Don't know if this was changed at some point.
For our windows slave it is "file:/D:/jenkins-slave/slave-agent.jnlp", which works.
The jnlpUrl parameter needs to be an http or https link to your Jenkins master, e.g. http://jenkins.yourco.com/computer/slavename/slave-agent.jnlp -it won't work as a file URL.

Unable to keep Selenium Server Running after Putty Close

First, install the Selenium Server:
Download a distribution archive of Selenium Server.
Unzip the distribution archive and copy selenium-server-standalone-2.9.0.jar (check the version suffix) to /usr/local/bin, for instance.
Start the Selenium Server server by running java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar.
I can let it run but when i close my putty, the server shuts down. Is it suppose to be that way? As in, does the code initialize the server when they need? or how do I find a way to keep it running?.
This is normal, when you close putty all your commands will be killed.
To keep your commands running, you need either to :
Create a script that will launch this command
run your command using : nohup java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar &

Package plink with jar

I have written a code (Java using eclipse Juno) which uses plink (C: installation) to connect to a remote server.
String command = "C:\\Program Files\\PuTTY\\plink -load session-name -l login -pw password";
Process p = runtime.exec (command);
Is there anyway I can safely export it (putty/plink) along with the jar file. This is so as there would not be any need of separate installation. I would also have to alter the code to call plink locally.
Thanks.
Use jar utility that comes with Java SDK to package putty executables to your application jar file.
Upon installation you can extract your exe file to a folder. And later call it from your code.
I am using the below code in plink.
"C:\Users\YXS8699\Desktop\Desktop\ansi165\x86\ansicon.exe \"C:\Progra~1\PuTTY\plink.exe\" ";
It was working fine.
Now when we run the plink command to connect WYSE50 terminal. I am facing the below issue
Command Prompt:
"C:\Program Files\PuTTY\plink.exe" CPHPQPU1.homedepot.com -l dbxd -pw 123summer -t WYSE50
Using keyboard-interactive authentication.
Password:
Now it is not working fine. Please give me some inputs.
Regards,
Yellappa

Running Java application on server

I have access to a server using SSH. I need to run a stand-alone Java application on it to access a MySQL server installed there. How do I go about in doing this?
Assuming you have the requirement to copy the JAR file on the *nix box and then run it(and not connect a Java process to it remotely)
Create a standalone JAR which contains all the dependencies required to run the application
Make sure you have Java installed on that machine
Assuming it's a *nix box, set the $PATH environment variable to point to $JAVA_HOME/bin
Log on to that box using a SSH client. Any decent SSH client also comes with a FTP plugin which allows you to transfer files between your local box and the server
Copy the JAR to the appropriate directory and run it using the java -jar your.jar command
Assuming it is a linux machine, you have to connect to by using SSH it and use scp command to upload the files and deploy it...
than you have to run the JAR you deployed:
java -jar /path/to/file.jar
Or, provide more details please

Categories