Hello,
I need to make a java program to run a script (a batch) and I do not know where to begin. (The batch is to connect via ftp to a remote unix server and download files). Any help regarding this topic is appreciated. Thanks in advance.
Hello,
I need to make a java program to run a script (a batch) and I do not know where to begin. (The batch is to connect via ftp to a remote unix server and download files). Any help regarding this topic is appreciated. Thanks in advance.
Hello,
Why run a bash script to execute ftp commands when you can do it directly in Java code, with good API? You can also do that with the protocol ssh. And if for a specific reason, you have to go through your bash file, then looks toward Runtime.exec (). I think you can use this method in your code. See, if this works in your code then let me know and also if it does not work then tell me.
Hello,
Try this code, if it works well and good.
I hope the above code will solve your problem.Code:Runtime rntm = rntm.getRuntime(); try { rntm.exec(New String[] {C:\\some.bat "} ); } wrestling (IOException e1) { e1.printStackTrace(); }
Hello,
Just have a look at the batch file, it should be something like this
Code:@ Echo off : Start echo 1 : Menu1 echo 2 : Menu2 echo 3 : Menu3 set / p chc = choose a number. if % chc% == not'' set chc =% chc: ~0,1% if % chc% ==1 goto Menu1 if % chc% ==2 goto Menu2 if % chc% ==3 goto Menu3 echo% chc% nIs not good! goto top : Menu1 echo Hello & goto: eof : Menu2 echo Goodbye & goto: eof : Menu3 Farewell & echo goto: eof
Hello,
Take a look at the following code, it may help you.
Code:import java.io.IOException; public class src { public src(){ Runtime rn = rn.getRuntime(); try { rn.exec(New String[] {D:\\some.bat "} ); } wrestling (IOException e1) { e1.printStackTrace(); } } public static void hand(String []args){ src = scNew src(); System.out.println("Hello"): } }
Bookmarks