Running CMD command from process.exec
I've been chopping this code up so forgive me if this is a mess, however I cannot figure out why this command simply will not work. It never seems to attempt to sign the jar files. I've also tried to sign the jar file by using an output stream. I can run the System.out of the payload from the CMD and it works fine.
When this method is executed it seems to loop over like nothing is happening.
private void signJar(String jarPath)
String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
try {
Process proc = Runtime.getRuntime ().exec("cmd /c " + payload);
InputStream inputstream = proc.getInputStream();
InputStream errorstream = proc.getErrorStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
InputStreamReader errorstreamreader = new InputStreamReader(errorstream);
BufferedReader inputreader = new BufferedReader(inputstreamreader);
BufferedReader errorreader = new BufferedReader(errorstreamreader);
while ((line = inputreader.readLine()) != null) {
d.asyncExec(new Runnable() {
public void run(){
l.setText(line + "\n" + l.getText());
while ((line = errorreader.readLine()) != null) {
d.asyncExec(new Runnable() {
public void run(){
l.setText(line + "\n" + l.getText());
errorreader.close();
inputreader.close();
return;
catch(IOException e)
e.printStackTrace();
return;
}
sabre150 wrote:
You probably have a deadlock since your code falls for at least 2 of the traps described in the 4 sections of [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html].
Thanks, I checked this out and decided to implement one of the methods he had, however, now I am getting an illegal argument exception. I think it is because of my payload, but I am not sure how to fix it. I know everything is formatted properly to input it in the console manually.
private void signJar(String jarPath)
String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
String cmds[] = {"cmd","/c",payload};
if (cmds.length < 1)
System.out.println("USAGE: java GoodWindowsExec <cmd>");
System.exit(1);
try
String[] cmd = new String[3];
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = cmds[2];
Runtime rt = Runtime.getRuntime();
System.out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec(cmd);
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
}Updated with different code still same error
EDIT: I should pay closer attention and stop trying to copy and paste code. I see where he says you can't use it like the command line...
Similar Messages
-
Unable to run curl command from process c#
Below is the curl command i am trying to run from c# script and i failed to execute please help
curl -K config.cfg
http://10.10.10.10:8080/MyApp/task
string curlDirectory = "E:\\application";
string curlArg1 = " -K ";
string curlArg2 = "config.cfg";
string curlArg3 = " http://10.10.10.10:8080/MyApp/task";
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
StreamWriter sw = process.StandardInput;
sw.WriteLine("cd " + curlDirectory);
sw.WriteLine("curl " + curlArg1 + curlArg2 + curlArg3);
sw.WriteLine("exit");
sw.Close();
C:>cd E:\application\
E:\application>curl -K config.cfg
http://10.10.10.10:8080/MyApp/task
E:\application>exitDid you get any error? can you remove the below line and try:
process.StartInfo.CreateNoWindow = true;
Fouad Roumieh -
Running ls command from Java stroed procedure no output
Hi ,
I am trying to run ls command from java stored procedure in oracle
Process p = Runtime.getRuntime().exec("ls");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("output of the command run:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
from java stored procedure in oracle.
i get output of println statments but it does not go into while loop to print from stdInput.
Result of running Java stored procedure is -
output of the command run:
Call completed.
when i run the program on client side it works fine.
Has anybody tried this from java stroed procedure.
Thanks,
JagJag,
Actually, the question of whether it works for me seems to depend on the version of the OS (or Oracle). On RedHat Linux (Oracle 8.1.6) it didn't work at all, but on Solaris (Oracle 9.0.2) it did. Here's the output from that run:
SQL> /
output of the command run:
init.ora
initDBPart9i.DBPSun01.ora
initdw.ora
lkDBPART9I
orapw
orapwDBPart9i
spfileDBPart9i.ora
Done
PL/SQL procedure successfully completed.
But, I did need to change a line of your code to this:
Process p = Runtime.getRuntime().exec("/usr/bin/ls");
your original was:
Process p = Runtime.getRuntime().exec("ls");
You might consider, if possible, use of some of the Java File classes instead of ls, as this might make things more predictable for you. There were some examples in oramag.com a few months ago, but they were pretty simple (you might not need them).
Hope this helps,
-Dan
http://www.compuware.com/products/devpartner/db/oracle_debug.htm
Debug PL/SQL and Java in the Oracle Database -
Ways to run dir command in Process and get Output
Hello,
In one of the control in our web application, User can select any directory from his work area and can get list of directories and content of directories i.e. list of files. As working on file object is really slow so the performance is extremely poor. I am thinking of using Process object and run dir command for any directory selected by user and show the directory listing to user.
Do you guys think it would be possibleIts always good to work with IO buffer than low level file api. That should be irrelevant to the question as asked (if not then there might be other problems.)This is no way irrelevant but its a fact. Working with Java File api to traverse the content of the directory is really painful. Because we currently use file api to help user to traverse thru her work area.
BTW, there are two servers. One running the app and the other have all users work areas. User can traverse the workareas content by using something \\server1\workarea1\user1\folder1 etc... in the app to see the content of any folder.A "server" in this context would be an "application" such as something like tomcat. Your client would then ask the "server" for information.
In your case you are dealing with another file system via the windows remote file system access. So per my question it is not another "server".A server is what providing service to a client and in our case its a app server with a web app in it. The users use the web app to manage their work area(which is another file server).
The app server and file server and physically two separate machines.
So again, I am back to my first question, how can run dir command using Process object and get the buffer.
Till now, I have done this
ProcessBuilder pb = new ProcessBuilder("cmd", "dir", "c:/");
pb.directory( new File("C:/temp")); // Or whatever directory you want for cwd
Map<String,String> env = pb.environment();
env.put("PATH", "C:/temp");
try {
Process process = pb.start();
InputStream inStream = process.getInputStream();
new AsyncPipe(process.getErrorStream(), System.out).start();
new AsyncPipe(process.getInputStream(), System.out).start();
final int returnCode = process.waitFor();
System.out.println("Return code is " + returnCode);
System.out.println("\nExit value = " + inStream + "\n");
} catch (Exception e) {
e.printStackTrace();
}However it simply opens command prompt -
Running Unix Command from WEB-APPLICATION
Hi all,
I want to run unix command from a java-based web application. the basic code part is this ---
public class RunCommand
public String runIt()
String s = null, returnString = "";
Process p=null;
try
Runtime rt = Runtime.getRuntime();
p = rt.exec("sh testPOC.ksh");
p.waitFor();
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
returnString += "Here is the standard output of the command:<br>";
while ((s = stdInput.readLine()) != null) {
returnString += s;
// read any errors from the attempted command
returnString += "Here is the standard error of the command (if any): <br>";
while ((s = stdError.readLine()) != null) {
returnString += s;
catch (IOException e)
returnString += "exception happened - here's what I know: ";
returnString += "error-> " + e.getMessage();
catch(Exception e)
returnString += "exception happened - here's what I know: ";
returnString += "error-> " + e.getMessage();
return returnString;
}this class is kept as an inner class. The control comes to its outer class, from servlet, from which the runit() is called. but the exception is occuring at line of p=rt.exec(.....). it tells "<command name> : not found transaction completed" [got this using getMessage() method].
i am unable to show(and see, too) the stacktrace, because i don't have access to that test environment and its log. i can't run this in local because its windows one.
now can anyone tell me, where is the problem. is there any limitation in web application server/container? this was successful when i used command prompt writing a .java file. Please help me. Thanks in advance...Friends, i've got, where the problem is.
when we run a class file directly from a command prompt, we get an environment with that shell window. but for a servlet application running these kind of commands from a class creates kind of child processes. each and every command is executed as a child process of jvm and don't get those environment. we have 'PATH' variable in the environment. when a command (say, 'dir' or 'sh' or 'ls', etc.) is executed, the shell first search for that executable file (i.e. dir / sh / ls) in the given paths in the variable 'PATH'. this is not available for the child commands of jvm. hence the basic commands are searched in the current directory of the jvm and they are failed.
i solved the problem giving full path of the commands. like :
p = rt.exec("/bin/sh runningScript.ksh") -
Running ssh command from java and then answering password prompt
Hi,
I have a situation that has not solved yet. I am running ssh command from unix terminal without any problem, and then i enter password.
For example :
[oracle@fuata]:/export/home/oracle> ssh -N [email protected] -L 9901:127.0.0.1:9999
Password:
It is working. I have question that how can i perform this in java? I am thinking that i can run ssh command by using Runtime Class, it is ok. But how can i answer the password? I am a bit confused. Is there any example looks like this?
Thanks for responses.futi wrote:
Thanx. Firstly i insisted to do this without jsch but actually this is harder than jsch. I edit some of code pieces PortForwardingL.java and could run it. It works problem-free. Could you say why you "insisted" on this approach. It can't be for speed+ since jsch is very fast. It can't be for portability+ since jsch is portable but the use of Runtime.exec() requires the installation of ssh software. It can't be because of limitations+ since jsch is a fully featured library. It can't be for security+ since jsch is secure. It can't be for ease of use+ since jsch is much easier to use than ssh with Runtime.exec(). Unless it's a licensing issue, it can't be for commercial+ reasons since jsch is free. The only reason I can think of why one would "insisted" on this approach is if it is for some college project. -
Hi All!!
Which package can help me to run OS command from SQL script?
Thanks.If you are using SQL*Plus to execute the script, you can use the SQL*Plus command HOST. If you are trying to execute an operating system command from a PL/SQL block (i.e. a stored procedure), you would need to use an external procedure or a Java stored procedure that uses Java's shell functionality.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Is it possible to run host command from SAP environment? How do you run?
Hi
Is it possible to run host command from SAP environment? How do you run?
Thank YouHello Subhash
You will more details in the following thread:
Re: How to define command for SXPG_COMMAND_EXECUTE
Regards
Uwe -
Running sqlldr command from PL/SQL Block
DECLARE
BEGIN
END;In SQL * plus we can run DOS commands using the following command
HOST DIR
HOST DIR/P
But When we can't run the HOST command in PL/SQL Block..
I have to Run sqlldr command from PL/SQL Block..
i tried as follows
DECLARE
BEGIN
EXECUTE IMMEDIATE ' host sqlldr control= bad= ';
END;
By
BalaNagaRaju -
How to run OS commands from PL/SQL???
Hi
Is there any way to run OS commands(Windows Platform) from within PL/SQL?
ThanksAPC,
I am working on Discoverer, having lots of BAs & Workbooks created & stored in Database. Now if i want to move all the workbooks from one place to another (like from development to test or production) i can use Command line interface of Disco to do this. But i don't see any option there to export all the workbooks, so i thought of writing a pl/sql to get all the workbook names from the EUL then fire export Command for each record(although not a good practice but its a one time work). This is the place where i need to run OS command from within PL/SQL. Although it doesn't seem possible now(as you all said) without external procedure.
Lastly, you are right that "Oracle make databases not operating systems" but my first impression/comment about oracle is:
"Oracle is far Bigger, Powerful, Complex, Vast and Interesting System than any other..." so i believe it can do/capable doing anything :-)
thx Ashutosh,
Host is definitely an option but i can't run it from pl/sql(that i am looking for).. -
Running curl command from a java program using Runtime.getRuntime.exec
for some reason my curl command does not run when I run it from within my java program and errors out with "https protocol not supported". This same curl command however runs fine from any directory on my red hat linux system.
To debug the problem, I printed my curl command from the java program before calling Runtime.getRuntime.exec command and then used this o/p to run from the command line and it runs fine.
I am not using libcurl or anything else, I am running a simple curl command as a command line utility from inside a Java program.
Any ideas on why this might be happening?thanks a lot for your response. The reason why I am using curl is because I need to use certificates and keys to gain access to the internal server. So I use curl "<url> --cert <path to the certificate>" --key "<path to the key>". If you don't mid could you please tell me which version of curl you are using.
I am using 7.15 in my system.
Below is the code which errors out.
public int execCurlCmd(String command)
String s = null;
try {
// run the Unix "ps -ef" command
Process p = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
return(0);
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
return(-1);
} -
hi I am using this code which needs to copy file
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RunSystemCommand {
public static void main(String args[]) {
String s = null;
// system command to run
String cmd = "copy a.txt b.txt";
// set the working directory for the OS command processor
File workDir = new File("c:
temp");
try {
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
int i = p.waitFor();
if (i == 0){
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
else {
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
catch (Exception e) {
System.out.println(e);
it doesnt work,the error is
java.io.IOException: CreateProcess: copy a.txt b.txt error=2
thx,ShaiIf you are using SQL*Plus to execute the script, you can use the SQL*Plus command HOST. If you are trying to execute an operating system command from a PL/SQL block (i.e. a stored procedure), you would need to use an external procedure or a Java stored procedure that uses Java's shell functionality.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Problem while running dos command from java program
Dear friends,
I need to terminate a running jar file from my java program which is running in the windows os.
For that i have an dos command to find process id of java program and kill by using tskill command.
Command to find process id is,
wmic /output:ProcessList.txt process where "name='java.exe'" get commandline,processid
This command gives the ProcessList.txt file and it contains the processid. I have to read this file to find the processid.
when i execute this command in dos prompt, it gives the processid in the ProcessList.txt file. But when i execute the same command in java program it keeps running mode only.
Code to run this command is,
public class KillProcess {
public static void main(String args[]) {
KillProcess kProcess = new KillProcess();
kProcess.getRunningProcess();
kProcess = new KillProcess();
kProcess.readProcessFile();
public void getRunningProcess() {
String cmd = "wmic /output:ProcessList.txt process where \"name='java.exe'\" get commandline,processid";
try {
Runtime run = Runtime.getRuntime();
Process process = run.exec(cmd);
int i = process.waitFor();
String s = null;
if(i==0) {
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(process.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println("--> "+s);
} else {
BufferedReader stdError = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
while ((s = stdError.readLine()) != null) {
System.out.println("====> "+ s);
System.out.println("Running process End....");
} catch(Exception e) {
e.printStackTrace();
public String readProcessFile() {
System.out.println("Read Process File...");
File file = null;
FileInputStream fis = null;
BufferedReader br = null;
String pixieLoc = "";
try {
file = new File("ProcessList.txt");
if (file.exists() && file.length() > 0) {
fis = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(fis, "UTF-16"));
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
} else {
System.out.println("No such file");
} catch (Exception e) {
e.printStackTrace();
return pixieLoc;
} when i remove the process.waitFor(), then while reading the ProcessList.txt file, it says "No such file".
if i give process.waitFor(), then it's in running mode and program is not completed.
Colud anyone please tell me how to handle this situation?
or Is there anyother way to kill the one running process in windows from java program?
Thanks in advance,
SathishHi masijade,
The modified code is,
class StreamGobbler extends Thread
InputStream is;
String type;
StreamGobbler(InputStream is, String type)
this.is = is;
this.type = type;
public void run()
try
InputStreamReader isr = new InputStreamReader(is, "UTF-16");
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
ioe.printStackTrace();
public class GoodWindowsExec
public static void main(String args[])
try
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
if( osName.equals( "Windows 95" ) )
cmd[0] = "command.com" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
} else {
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
Runtime rt = Runtime.getRuntime();
System.out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec(cmd);
System.out.println("Executing.......");
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
}when i execute the above code, i got output as,
Execing cmd.exe /C wmic process where "name='java.exe'" get commandline,processid
and keeps in running mode only.
If i execute the same command in dos prompt,
CommandLine
ProcessId
java -classpath ./../lib/StartApp.jar;./../lib; com.abc.middle.startapp.StartAPP 2468
If i modify the command as,
cmd.exe /C wmic process where "name='java.exe'" get commandline,processid > 123.txt
and keeps in running mode only.
If i open the file when program in running mode, no contents in that file.
If i terminte the program and if i open the file, then i find the processid in that file.
Can you help me to solve this issue? -
Running cmd commands through java
Hi,
I am trying to run few dos commands through java using Runtime.exec("command") but I am getting following error
commmand is cd D:\CodeMerge\A\
java.io.IOException: CreateProcess: cd.. error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at createDirectory.main(createDirectory.java:24)
Basically what I am looking for is this:
1) My program is in D:\Amit\RM
2) I want to get out to D:\ go to CodeMerge\A\.
3) Create folder with curretn date as name of the folder
Hence I am doing
rTime.exec("cd../..");
rTime.exec("cd D:\CodeMerge\A\");
rTime.exec("mkdir "+date);
Can anybody tell me why I am getting this error
JountyU can run either DOS Commands or UNIX Commands thru the following Java Program
Written By BalaNagaraju Malisetti
contact: [email protected]
import java.io.*;
public class RunBdiff
public static String rununixcmd(String v_prev_path,String v_curr_path,String v_delta_path,String v_beg,String v_len)
String s = null;
FileOutputStream fos;
DataOutputStream dos;
try
int v_int_beg = Integer.parseInt(v_beg);
int v_int_len=Integer.parseInt(v_len);
int v_int_end=(v_int_beg+v_int_len)-1;
String v_pos1=String.valueOf((v_int_beg+2));
String v_pos2=String.valueOf((v_int_end+2));
String cmd1 = "bdiff ";
String cmd2=v_prev_path;
String cmd3=" ";
String cmd4=v_curr_path;
String cmd5="| grep '^>'";
String cmd6="| cut -c";
String cmd7=v_pos1+"-"+v_pos2;
String cmd8="| sort ";
String cmd9="| uniq ";
String cmd=cmd1+cmd2+cmd3+cmd4+cmd5+cmd6+cmd7+cmd8+cmd9;
String[] commands = {"/bin/csh","-c",cmd}; //in Unix
//String[] commands = {"cmd.exe","-c",cmd}; //in Windows
Process p = Runtime.getRuntime().exec(commands);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
File file = new File(v_delta_path);
fos = new FileOutputStream(file);
dos=new DataOutputStream(fos);
//Writing the output of bdiff command to Delta File
while ((s = stdInput.readLine()) != null)
dos.writeChars(s);
//Return Error Message to Calling Procedure
while ((s = stdError.readLine()) != null)
return s;
return s;
catch (IOException e)
return String.valueOf(e);
public static void main(String args[])
String msg=rununixcmd("/home/g_anil/MS_ADDRESS1.dat","/home/g_anil/MS_ADDRESS2.dat","/home/g_anil/MS_ADDRESS_DELTA.dat","1","9");
************************************************************************************************************************************** -
Running System commands using Runtime.exec()
I'm trying to run an example from "The Java Programming Language" book by Arnold, Gosling and Holmes. I'm trying to run a system level command and get the results. The code looks like:
public static String[] runCommand(String cmd) {
String[] outputData= null;
String[] cmdArray = {"/usr/bin/ls", "-l", "/tmp"};
try {
Process child = Runtime.getRuntime().exec(cmdArray);
InputStream in = child.getInputStream();
InputStreamReader reader = new InputStreamReader(output);
BufferedReader = new BufferedReader(reader);
// read the commands output
int counter = 0;
String line;
while ((line = input.readLine()) != null)
outputData[counter++]= line;
if (child.waitFor() != 0){ // error when it's not 0
System.out.println("Couldn't run the command.");
System.out.println("It produced the following error message : " + child.exitValue());
outputData = null;
} catch (Exception e){
System.out.println("It got here!");
System.out.println("It produced the following error message : " + e.getMessage());
outputData = null;
return outputData;
It gets to the while line, trys to run the input.readLine() and kicks out the exception that looks like:
It got here!
It produced the following error message : null
I know it gets to the input.readLine() because I had a whole lot more try blocks in there, but for simplicity left it out (so it look like the code in the book, which I tried originally). When I run the same command from the command line (on our Sun Solaris 2.8 system) I get results back. I'm not sure what I'm doing wrong. Any help would be greatly appreciated. Thanks.Hi, duffymo, hope you can help me. Consider this servlet code:
String theCommand = "csh /export/home/gls03/sasstuff/runsas.csh /export/home/g
ls03/sasstuff/gary2.sas";
//Create a parent Process for the sas program subprocess:
Process p = rt.exec(theCommand);
System.out.println("after call to rt.exec(theCommand)");
Here is the runsas.csh script:
#!/bin/csh
setenv LD_LIBRARY_PATH /opt/sybase/lib:/usr/lib:/usr/openwin/lib:/opt/SUNWspro/S
C2.0.1
setenv SASROOT /usr/local/CDC/SAS_8.2
setenv XKEYSYMDB /usr/local/CDC/SAS_8.2/X11/resource_files/XKeysymDB
$SASROOT/sas -sasuser /hpnpages/cgi-bin/applinks/hospcap/tmp $1
The execution never gets to the println statment, here is the error:
class java.io.IOException Exception. Message: CreateProcess: csh /export/home/g
ls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas error=2
java.io.IOException: CreateProcess: csh /export/home/gls03/sasstuff/runsas.csh /
export/home/gls03/sasstuff/gary2.sas error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:551)
at java.lang.Runtime.exec(Runtime.java:477)
at java.lang.Runtime.exec(Runtime.java:443)
at sasRunnerNew.doPost(sasRunnerNew.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:262)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at us.ny.state.health.hin.hinutil.HinFilter.doFilter(HinFilter.java:124)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2643)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2359)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
The command runs fine in unix.
I've also tried using these as arguments to exec:
String theCommand = "/bin/csh /export/home/gls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas";
String[] theCommand = {"csh", "/export/home/gls03/sasstuff/runsas.csh", "/export/home/gls03/sasstuff/gary2.sas"};
These generate the same error. I'm thinking this is a sas-specific problem.
Thanks for any help. Gary
Maybe you are looking for
-
I would like to know how to change the order that my printer prints. It is now printing from last to first. I want to change it to first to last. I have a Mac with operating 10.9 operating system. I checked in Hp Utility could find whern to change pa
-
Help Product Improvement Program dialog box won't go away
When I re-opened the beta version of Fireworks CS4 last night, there was a dialog box asking me whether or not I wanted to participate in helping Adobe with product enhancement by submitting information on my usage of Fireworks, but the bloody thing
-
Printing a PDF file saves .prn but won't go to printer
Windows 7 Utlimate, 32-bit.. Acrobat Pro 9.5.5. An HP Officjet and a Brother laser printer, both networked. Whenever I try to print from Acrobat, instead of going to my chosen printer I get a Save dialog box for a .prn file. Thus, I can no longer pri
-
Alter leading of a range of text in a title?
I thought you were supposed to be able to do this. How do you alter the leading of just two lines of text within a title text box without affecting the leading of all the other lines of text within the text box? I can alter the kerning of a few lines
-
Help with error select case statement (ORA-00932: inconsistent datatypes)
Hi, I'm struggling to get my sql query work on Oracle.. I have a table MyTable with 5 columns ( Column1, Column2, Column3, Column4, Column5 ) all are of type NVARCHAR2. I need to check whether Column 3, Column 4 are empty or not in that order..and if