Forums Register Login

ProcessBuilder Issue

+Pie Number of slices to send: Send
Hi

Below is my code that i am using to copy file from one location to another in linux environment.

Getting not any exception, but file is not getting copy at tgtPath. Please Advice if anything missing here.
+Pie Number of slices to send: Send
Since you are not using a shell to execute 'cp' you need to provide the full path to the 'cp' executable e.g. "/bin/cp" BUT BUT BUT you are falling for 3 of the traps outlined in http://www.javaworld.com/jw-12-2000/jw-1229-traps.html . You are not handling the process 'stderr' , you are not handling the process 'stdout' and you are ignoring the process return code. Although the 'traps' article is very old and deals with Runtime.exec() the recommendations still apply and you should follow them to the letter.

Why are you resorting to using ProcessBuilder to copy a file? It is very easy in pure Java.
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1581 times.
Similar Threads
ProcessBuilder Constructor
Catching InputStream from Runtime/Process
how to finish the process forcibly?
GUI update.
Input redirection in Java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:40:52.