I need to execute linux commands from JSP.
It is working fine.
But i need to start some sh file in a particular directory in linux through JSP.
I have a serious problem
I want to run a Linux command using a Java class with the runtime interface, there is a command to create a folder named eg "My Folder", with a space
For create the Unix command is easy to do either:
mkdir My\ Folder
or
mkdir "My Folder"
But how to translate this in Java, I tried with two commands :
Runtime.exec("mkdir My\ Folder")
Runtime.exec("mkdir \"My Folder\"")
H
I am using the following code to execute an SH file in Linux
Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", file.getPath() });
This code works however I can't use the screen command in the SH file when executing it from Java, I get this error
Must be connected to a terminal.
So is it possible to "connect" java to a terminal?
I am trying to call a bash script from a java class .
This is my java program
import java.io.File;
public class RunBuild {
public static void main(String[] args) {
File wd = new File("/home/sai/Jan5WS/ATCore/bin/");
System.out.println("Working Directory: " + wd);
Process proc = null;
try {
proc = Runtime.getRuntime().exec(" .
I've a shared server Linux based on which I am facing a weird problem. I am trying to execute by PHP, the following command and it runs ok; returning me the PHP install path /usr/bin/php.
exec('which php');// This runs so exec is not disabled
but any command i try to execute with exec('php ...'); fails returning me an array of 98 to 114 elements randomly which almost has garbage all over.
I am trying to execute a find command using java code. I did the following:
sysCommand = "find . -name '*out*' > file1"
Runtime runtimeObj = Runtime.getRuntime();
try {
Process processObj = runtimeObj.exec(sysCommand);
processObj.waitFor();
...
This Linux command is executed when I use command line but fails in Java, why?
I wrote a script on bash and it ran with errors. I noticed that when my scripts have errors they generate another file with the name of my script, but with a tilde "~" in the front. Can someone explain the significance of this?
Thanks!
Gaby
I have written a small java code with getRuntime() API to copy files from One directory to another, it it failing, I am not able to understand why?
I am trying to run a GATE application via jetty web application server in Ubuntu.