Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am writing a Java code for Linux RHEL 5 machine. The requirement is that while sitting at machine A, I should be able to edit some files in a remote machine B. Both machine A & B are RHEL. Now the following possibilities are there. Can anyone please suggest which is better or if any other way is there:
Write a shell script to do this. Execute the shell script from A such that changes happen in B
Write a java code on A, that is able to login to B and edit files in B.
Write a java file editing utility (pattern-matching thing). Push this util on B through another java code. Execute the file edit util in B. Somehow the trigger for executing the util in B should also be given by A
Thanks
Eclipse Remote System Explorer lets you do just that: http://www.eclipse.org/tm/
You can also use java library to do that :
http://www.jcraft.com/jsch/
Check out the examples link.
It depends on your needs but I think it is easier and faster to do that with bash scripts and some linux tools like nc, telnet or ssh for instance.
With ssh is as simple as:
ssh user#remote mkdir /tmp/new_directory
I hope it helps...
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
I have found a Java application repository on GitHub which provides the application in JAR format and in the native binary format for different operating systems such as MacOS, Windows, Linux.
I am able to execute the JAR file using the java -jar command but I would like to run the native binary file so users can execute it without installing the Java in their system.
Can someone please inform me how can I run the binary file on Macos? I tried to search and found the command chmod +x name-of-binary but this command does not do anything.
I am really new to this and do not have much idea about this so any suggestion would be really helpful.
The most simple way would be to either open a terminal and manually running the binary, like so:
./<name-of-file>
This would only work if you are running the file in a user who has execution privileges on that file. if you run into trouble with priviliges, that's where I would use chmod.
If you need any more specific help, I would recommend posting the link to that GitHub repo for us to look at, and telling us what is it that it should do.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm new to docker and want to understand on how to build a docker image that I can deploy in my organization's internal cloud
Currently, our vendor has provided us with a shell script which we use to install a java application on a VM.
Is there any way to build an image for this java application using this shell script?
Thanks.
Yes, just use
FROM <base_image>
to define the base image you want to start with (i.e. the best suited environement for you application to work: typically you would use Ubuntu 16.04, or maybe an Alpine linux distribution if you want to be more lightweight
then
RUN <shell-script>
to install you application
(note that if there are dependencies needed for the script to run (like JAVA), you will need to RUN the install steps for the dependencies before this RUN command)
and then
CMD <command-to-start-the-app>
to start the app.
A good place to start with Docker is to look up the official images of known services on github and see how they do it.
There are many images using JAVA, with a base like https://github.com/dockerfile/java
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am beginner in Java. I have a USB stick with some information stored.
I want to write Java code on Linux platform. After inserting USB stick in Linux machine, I want to mount USB stick in Java code and read the USB Stick content.
I need help to write Java code to Mount USB Stick and read the USB content.
After spending some time I got to know that Shell Command is the best way to execute in Java.
I need help to write Shell command to identify the Mounting Location in Java.
Thanks,
Manoj
i know this wont be helpful but... WHY?!?!? lol
also i don't know any thing about java, but i did find this:
Want to invoke a linux shell command from Java
i suppose if you're asking how to find the usb device and mount with a linux command... you're going to need to watch DMESG or log/messages or log/syslog depending on distro...
i dont know, i hope this points you in the right direction...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm working on a java program that needs to be able to connect to a remote server and execute system commands. How would I create a command shell that looked exactly the same as windows command prompt for the client, but executes the commands on the remote server? Thx in advance
It's possible to do, but it's not easy - java has never been great for command-line operation. If you want to do it, look for java-based SSH implementations.
On the other hand, if the user will be running the java program from the command-line, it may be possible to execute an ssh command on the same terminal.
Here is a page that describes executing an external program from java: http://alvinalexander.com/java/java-exec-processbuilder-process-1.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I’m new to python scripting and I need to install Java using python script . please suggest a method to do this.
Thanks all.
If i am not wrong you are looking for silent installation of Java. Here is a link that explains the same:
Silent installation of Java
Next you would want to run this command using python. For this you can use subprocess in python. Below is a link explaining it:
Using subprocess in Python
You want to display error stream too, so use the subprocess.Popen as:
process = subprocess.Popen(['command plus args as in above link'],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
out contains the output of the above command and err contains the error stream.
I would suggest you to install java from command line first, and then use this command in python script.
To install mySql or even tcl, follow similar steps,
1. Find how to install using command line
2. Execute the same command using python
Also, there may already be existing packages to do your job, if so you can use them.