0

I have some shell commands that would get dynamically generated in my scala script, how can I run them inside the scala script?

Code snippet below:

var filename = xxxxxx

filename = "This File"

import sys.process._
"hdfs dfs -rm " + filename 

Literally I want to run shell command: hdfs dfs -rm "This File"

Thank you very much.

1 Answer 1

1

There is a method called ! to run a command, using string interpolation of the filename variable, you can run it like this:

s"hdfs dfs -rm $filename".!

See more in this answer: https://stackoverflow.com/a/6013972/6176274

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.