File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Proc.exec() with spaces in command
Joined: Jun 26, 2008
Dec 16, 2009 13:10:30
I am trying to execute a command from within a groovy script. For instance
md5sum /home/user/some file name with a space
but any filename with a space is giving an error. I've tried the following without success.
def md5cmd = "md5sum $fileName"
Process proc = md5cmd.execute()
def md5cmd = "md5sum \"$fileName\""
Does anyone have any suggestions on how I can pass build up an argument list that will prevent the No such file or directory.
OS is ubuntu linux
I would be greatful for any suggestions
Joined: Oct 04, 2006
Dec 18, 2009 02:29:10
The solution to your problem (at least a solution that works on OS X) is to use a
// This works ProcessBuilder theBuilder = new ProcessBuilder("cat", "Desktop/my test file.txt") theBuilder.start().text // This does not work //"cat Desktop/my test file.txt".execute().text
Please let me know if this works in Ubuntu too.
I agree. Here's the link:
subject: Proc.exec() with spaces in command
ask for korn shell
Ant checksum task generates invalid MD5 file
Please HELP me in installing Mandrake 10.0
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013