• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

the question about copy files in unix use Runtime.exec?

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not familiar with the unix platform,but now i need copy files in unix use java's Runtime.exec.
in windows , i use



but in unix ,how can i do it?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not use pure Java code on all platforms?

But if you're determined to do this this way, the best UNIX equivalent of "cmd.exe /c start copy" is simply "cp".
 
alex han
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
Why not use pure Java code on all platforms?

But if you're determined to do this this way, the best UNIX equivalent of "cmd.exe /c start copy" is simply "cp".



many thanks,but what is the equivalent of "cmd.exe /c start" ?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"cmd.exe /c" means "run the command shell and execute the following command". "start" means, again, I believe, just "run the following command." And since "copy" is a shell built-in, at least the "cmd /c" is needed.

In UNIX, "cp" is an executable, and you can just execute it. "cp" is all you need. If you actually needed to run a shell, and have the shell run "cp", you could say

/bin/sh -c "cp file1 file2"

But as I said, you don't need to do that.
 
alex han
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
"cmd.exe /c" means "run the command shell and execute the following command". "start" means, again, I believe, just "run the following command." And since "copy" is a shell built-in, at least the "cmd /c" is needed.

In UNIX, "cp" is an executable, and you can just execute it. "cp" is all you need. If you actually needed to run a shell, and have the shell run "cp", you could say

/bin/sh -c "cp file1 file2"

But as I said, you don't need to do that.



yeah,it is very helpful,now i have understood, thanks
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would also recommend using the "man" manual pages for the "cp" command. There is difference in the syntax between coping a file and coping a directory structure using the command "cp".

At the command prompt on the unix system, just type:

[ November 21, 2005: Message edited by: Craig Jackson ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic