Process Runtime pass input

后端 未结 4 869
执笔经年
执笔经年 2021-01-03 15:02

I have rsync command to be run in a java program...the problem i am facing is that rsync requires a password to be entered and i am not understanding how to pass this passwo

4条回答
  •  生来不讨喜
    2021-01-03 15:23

    You can write to the output stream of the Process, to pass in any inputs. However, this will require you to have knowledge of rsync's behavior, for you must write the password to the outputstream only when the password prompt is detected (by reading the input stream of the Process).

    You may however, create a non-world readable password file, and pass the location of this password file using the --password-file option when you launch the rsync process from Java.

提交回复
热议问题