Executing MSSQL bcp from a servlet using getRuntime.exec()

Status
Not open for further replies.
Edit code below is fine, lack of sleep meant I was making sloppy mistakes elsewhere, ignore this thread.
Code:
 public static void main(String argv[]) {
	    try {
	      String[] params = {"cmd.exe","copy EmptyFile1.txt EmptyFile3.txt"};
	      Process p = Runtime.getRuntime().exec(params);
	      //p.waitFor();
	     // System.out.println(p.exitValue());
	    }
	    catch (Exception err) {
	      err.printStackTrace();
	    }
	  }
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
ell you aren't waiting for it to finish, nor looking at the return code...

What is your current directory at the point you try to launch the process? I would think that the relevant file doesn't exist. Also it's been a while but I'm not sure you will be able to call cmd that way on some windows servers based ont the normal permissions present for a web server. cmd.exe is locked down from server 2003 IIRC.
 
Status
Not open for further replies.