Reputation: 1218
I'm trying to run a command from Scala
val cmd = "scp -r /path/to/dir/* user@ip:target/dir"
print(cmd)
cmd.!!
if I copy the command inside the terminal it works without problem, but running it using the .!! method I obtain
/path/to/dir/*: No such file or directory
What could be the problem? thanks
Upvotes: 0
Views: 174
Reputation: 37832
Asterisk is expanded by bash
, so you'll need to get bash
to execute the command for you, can be done like this:
val cmd = "echo \"scp -r /path/to/dir/* user@ip:target/dir\" | bash"
print(cmd)
cmd.!!
Upvotes: 1