Process executes command problem

I have a shell command which mirror remote sftp server periodically. The command looks like

lftp … -e ‘set …; mirror … --verbose … <remote_src_path> <dest_local_path>’ ftp://

But when executing scala process

import scala.sys.process._
val command = … // lftp command
val output = command.!!

It throws an error message “open: unrecognized option ‘–verbose’”. In python this can be overcame by communicate function. How can I achieve this in Scala?

Thanks

Hello,

Parsing of the command line is a bit funky. I would write the command
line to a file and then run it using command “bash
”.

 Best, Oliver

You can invoke the “.!!” method on a plain string, which will do very simplistic parsing of the string into command and arguments (i.e. split it on any whitespace, without any regard to quotes/backslashes/whatever) - or you can do the splitting yourself:

  Seq("lftp", "-e", """set ...; mirror ... --verbose ...""", "ftp://").!!

Cheers,

Harald