无法使用scala.sys.process执行工作shell命令

无法使用scala.sys.process执行工作shell命令,scala,shell,Scala,Shell,在shell中运行时,成功执行以下命令 csvsql --db "postgresql://user:password@localhost:5432/samples" --table sample_table --insert /absolute.path.csv 但从scala运行时无法执行,如下所示: s"""csvsql --db "postgresql://user:password@localhost:5432/sample

在shell中运行时,成功执行以下命令

csvsql --db "postgresql://user:password@localhost:5432/samples" --table sample_table --insert /absolute.path.csv
但从scala运行时无法执行,如下所示:

s"""csvsql --db "postgresql://user:password@localhost:5432/samples" --table sample_table --insert /absolute.path.csv""" !!
出现以下错误:


ArgumentError:无法从字符串“p”解析rfc1738 URLostgresql://user:password@localhost:5432/samples“'

shell将在将参数传递给进程之前删除引号,因此需要从db字符串中删除引号。最好使用参数的
Seq
,而不是字符串:

Seq("csvsql", "--db", "postgresql://user:password@localhost:5432/samples", "--table", "sample_table", "--insert", "/absolute.path.csv") !!

尝试将字符串中的双引号更改为单引号。