I have an application running on a server which is doing stuff and writing everything it does to a log file.
I also have secondary application which is kind of like a monitoring panel also running on the server but is a different process. What I would like to do is the following:
I would like my monitoring file to be able to copy the log file which currently has a lock on it from the other application and then email it to me.
I have tried using scp to connect to the server and copy it manually to my computer(and it did work), however I would like to be able to do that through my java monitoring application. And I have no idea where to start.
I have tried using scp to connect to the server and copy it manually to my computer(and it did work)
The JSch library has a ScpFrom module that you can use to scp copy the data from the server to your computer or application. This can be done by one of the following:
Manually running the module (eg java -jar)
Copying the source of the module into your project and adding the JSch library to classpath (more programmatic control - preferred approach)
Using the library module programmatically eg String[] args = {user#remotehost:file1" "localfile"}; SCPFrom.main(args);
Related
I have a Spring web application which triggers a SAS job on a remote Linux server, the SAS job will generate a result file on the remote server upon finished. I need to display the result on my Spring application, so I want to create a listener for the directory changes on the server.
I have being looking at the java.nio library, but it looks like it only works local directories. Any ideas other than keep pinging the server through ssh? Thanks!
You might use FTP from org.apache.commons.net.ftp
Using FTP (or any other Java FTP library), you only need to check for the content on the remote directory.
If the directory supposedly is always empty, then when the first file appears your process will be triggered.
If the directory is not always empty, you might need to implement something to control which files are new, and which are not.
Please let me know if you need further assistance.
[Preconditions]
I have NFSv4 fileshare running on RHEL, and I can successfully mount shared folder on another RHEL machine and see it's content (Thus configuration seems fine).
[PROBLEM]
I would like to also read shared folder from java client code on Windows (without mounting file share anywhere) but currently no success.
[WHAT I'VE TRIED]
Tried YANFS but it only supports NFSv2 and NFSv3; also there's dCache library but it looks like it mostly NFS server (However I've looked through it, it has some client classes but I did not succeed in reading remote file share with it).
[QUESTION]
How to read remote NFSv4 shared folder from java client without mounting?
I have developed an app using Spark Java Framework (www.sparkjava.com). I am able to build the artifact on my windows as a JAR file. I can confirm I am able to run it via command line "java -jar App.jar Main.java". It hosts a web app at localhost:4567.
What's the most convenient/quickest way to load this onto an AWS server? I created an EC2 instance (AMI Instance), copied over the jar file to it, ran the command. The log seems to run successfully, but I can't hit the DNS server. It doesn't seem to be up.
I found the solution.
Log into AWS
Click on Instances and click on your Instance
In description, see Security Groups, click on your Security Group
In the Inbound tab, click on Add Rule
Add HTTP, HTTPS, and Custom
For Custom, set the Port to the port that you'd like to be
available to all incoming traffic. Hit apply.
i am new in aws. i created one ec2 instance and installed tomcat7, deployed java web application. after i want change inside my application like db.property file. how to change through java api.my all files are available in ebs volume. how to get particular file and modify and update through java programmatic.
Thanks,
Sriram
The AWS API doesn't let you access EBS volume contents directly. You need to log into the machine and make the changes.
If it's a Linux machine, you can do so via SSH.
You can use a command-line SSH client or an SSH client library, such as Jsch for Java.
Is it possible to have ANT restart your java application on a remote server from a build script? If so any pointers to where that might be defined?
I'm using ant now to push the new code over to the remote server but I still have to login to actually restart the app
Using the <sshexec> task you can do pretty much anything on a remote machine (assuming it's got an sshd running). If you don't want to worry about authenticating the ssh session every time, you can set up RSA keys.
<sshexec host="remotehost" username="remoteuser" command="/restart/application/command"/>
Heed the statement at the beginning of the above link:
This task depends on external libraries
You'll need to grab JCraft's JSch jar and put it on Ant's classpath.