我在Robot Framework测试中遇到ssh隧道问题。我用sshpass命令设置变量$ {command}。之后,我尝试通过Run Process或Run或Start Process在环境中运行此命令。
${command} Set Variable sshpass -p password ssh -q -L 1234:192.168.253.18:22 192.168.255.1 -N &
${process} Run Process ${command} cwd=${CURDIR} shell=True on_timeout=continue timeout=5
#${process} Start Process ${command} cwd=${CURDIR} shell=True stderr=${CURDIR}/stderr.txt stdout=${CURDIR}/stdout.txt
#${process} Run ${command}
如果我手动运行此命令,一切正常 - 创建ssh隧道,进程正在运行。
abc@abc:~/robot/EDA$ sshpass -p password ssh -q -L 1234:192.168.253.18:22 192.168.255.1 -N &
[1] 23634
abc@abc:~/robot/EDA$
如果我通过Run运行此关键字测试正在等待进程完成,但它等待无限。
20180525 21:46:35.752 - INFO - Starting process:
sshpass -p password ssh -q -L 1234:192.168.253.18:22 192.168.255.1 -N &
20180525 21:46:35.752 - DEBUG - Process configuration:
cwd: /home/robot/EDA/resources
shell: True
stdout: PIPE
stderr: PIPE
alias: None
env: None
20180525 21:46:35.762 - INFO - Waiting for process to complete.
如果我通过Start Process运行:
20180525 21:56:01.792 - INFO - +---- START KW: Process.Start Process [ ${command} | cwd=/home/robot/EDA/resources/ | shell=True | stderr=/home/robot/EDA/resources/stderr.txt | stdout=/home/robot/EDA/resources//stdout.txt ]
20180525 21:56:01.793 - INFO - Starting process:
sshpass -p password ssh -q -L 1234:192.168.253.18:22 192.168.255.1 -N &
20180525 21:56:01.793 - DEBUG - Process configuration:
cwd: /home/robot/EDA/resources/
shell: True
stdout: /home/robot/EDA/resources/stdout.txt
stderr: /home/robot/EDA/resources/stderr.txt
alias: None
env: None
20180525 21:56:01.801 - INFO - ${process} = 1
20180525 21:56:01.801 - INFO - +---- END KW: Process.Start Process (9)
20180525 21:56:01.802 - INFO - +--- END KW: EDA.Create Ssh Tunnel (12)
stdout.txt和stderr.txt为空。流程没有创建。
如果我通过Run:
运行此命令20180525 22:02:12.226 - INFO - +---- START KW: OperatingSystem.Run [ ${command} ]
20180525 22:02:12.230 - INFO - Running command 'sshpass -p password ssh -q -L 1234:192.168.253.18:22 192.168.255.1 -N 2>&1 &'.
并且测试也在等到无限。
有人可以帮我解决这个问题吗?