h*****a 发帖数: 1718 | 1 I am using Runtime.getRuntime.exec() to run the following unix command to
create a directory on a remote host.
ssh user@host "mkdir -p 'test'"
and it complains with the error below
zsh: no such file or directory: mkdir -p 'test'
Seems it incorrectly thinks the command after ssh is a file name.
Does anyone know how to fix it? |
g*****g 发帖数: 34805 | 2 Put the command in a script file, and run that script instead,
it's probably easier that way.
【在 h*****a 的大作中提到】 : I am using Runtime.getRuntime.exec() to run the following unix command to : create a directory on a remote host. : ssh user@host "mkdir -p 'test'" : and it complains with the error below : zsh: no such file or directory: mkdir -p 'test' : Seems it incorrectly thinks the command after ssh is a file name. : Does anyone know how to fix it?
|
h*****0 发帖数: 4889 | 3 when you get complicated options in you command, try to use this edition of
exec:
Runtime.exec(String[] cmdarray)
【在 h*****a 的大作中提到】 : I am using Runtime.getRuntime.exec() to run the following unix command to : create a directory on a remote host. : ssh user@host "mkdir -p 'test'" : and it complains with the error below : zsh: no such file or directory: mkdir -p 'test' : Seems it incorrectly thinks the command after ssh is a file name. : Does anyone know how to fix it?
|
h*****a 发帖数: 1718 | 4 Thanks for all replies. Changing to the API using the array argument solves
this problem.
The documentation of the Runtime class is not clear about the difference of
these different APIs.
of
【在 h*****0 的大作中提到】 : when you get complicated options in you command, try to use this edition of : exec: : Runtime.exec(String[] cmdarray)
|
h*****0 发帖数: 4889 | 5 well, it says the single String argument will be splitted by StringTokenizor
, and then apply the array edition. I guess a careful study of
StringTokenizor would makes you able to use the single String argument
edition. It's just unnecessary.
solves
of
【在 h*****a 的大作中提到】 : Thanks for all replies. Changing to the API using the array argument solves : this problem. : The documentation of the Runtime class is not clear about the difference of : these different APIs. : : of
|