IntelliJ Java IDE
The moose likes Groovy and the fly likes Proc.exec() with spaces in command Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark "Proc.exec() with spaces in command" Watch "Proc.exec() with spaces in command" New topic
Author

Proc.exec() with spaces in command

Kristian Jones
Greenhorn

Joined: Jun 26, 2008
Posts: 6
Hi
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()

and

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.

Note:
OS is ubuntu linux

I would be greatful for any suggestions

Ivan Krizsan
Bartender

Joined: Oct 04, 2006
Posts: 2186
Hi!
The solution to your problem (at least a solution that works on OS X) is to use a ProcessBuilder:

Please let me know if this works in Ubuntu too.
Best wishes!
 
 
subject: Proc.exec() with spaces in command
 
Threads others viewed
ask for korn shell
checksum
Ant checksum task generates invalid MD5 file
Please HELP me in installing Mandrake 10.0
md5sum Inconsistencies
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture