• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Proc.exec() with spaces in command

 
Kristian Jones
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic