Reputation: 6039
So I am sending this system command in Scala:
val command = "python other/evaluateAnswers.py 'chemistry earth' 'the chemistry of the world in champaign' 'the chemistry of the computer science world'"
command.!!
Here is a simplified version of my python code:
def main(argv):
# example run:
print(argv)
# do stuff here ...
if __name__ == '__main__':
main(sys.argv[1:])
If I run this directly inside terminal:
daniel$ python other/evaluateAnswers.py 'chemistry earth' 'the chemistry of the world in champaign' 'the chemistry of the computer science world'
Here is the result of print(argv)
in my python code:
['chemistry earth', 'the chemistry of the world in champaign', 'the chemistry of the computer science world']
which is correct.
While if I run this from scala via command.!!
I'd get the following in the output of print(argv)
:
["'chemistry", "earth'", "'the", 'chemistry', 'of', 'the', 'world', 'in', "champaign'", "'the", 'chemistry', 'of', 'the', 'computer', 'science', "world'"]
which is incorrect splitting.
Any ideas where I'm going wrong?
Upvotes: 3
Views: 437
Reputation: 6039
Manually splitting my scala command did the trick:
val command = Seq("python", "other/evaluateAnswers.py", "'chemistry earth'", "'the chemistry of the world in champaign'", "'the chemistry of the computer science world'")
command.!!
Upvotes: 2