记录服务器上的位置 - Robot Framework/CMD

Logging the location on the server - Robot Framework/CMD

我正在尝试使用应用程序 运行 登录到数据库服务器。我可以毫无问题地登录,但是当我尝试在服务器上登录工作目录时,它显示登录后的默认目录,而不是我更改的目录。

整个测试用例如下所示:

*** Settings ***
Library  SSHLibrary

*** Variables ***
${IP}  IP
${user}  user
${password}  password
*** Test Cases ***
CMD
    Open connection  ${IP}
    login  ${user}  ${password}
    execute command  cd gtms/bin
    ${pwd}  execute commanrd  pwd
    log  ${pwd}

当我使用 pwd 时,我希望获得有关我所在目录的信息,但它不起作用。我在日志中得到这个:

KEYWORD BuiltIn . Log ${pwd}
Documentation:  
Logs the given message with the given level.
Start / End / Elapsed:  20170807 16:07:14.266 / 20170807 16:07:14.267 /         
00:00:00.001
16:07:14.267    INFO    /home/ollie

谁能告诉我我做错了什么?

提前致谢。

Execute Command 总是在新的 shell 中运行指定的命令 - 因此第一次调用中的 cd 不会保留,如 [=14= 可见] 在第二次通话中。这实际上是其 documentation 中的示例:

The command is always executed in a new shell. Thus possible changes to the environment (e.g. changing working directory) are not visible to the later keywords:
${pwd}= Execute Command pwd
Should Be Equal ${pwd}  /home/johndoe
Execute Command cd /tmp 
${pwd}= Execute Command pwd
Should Be Equal ${pwd}  /home/johndoe

为了达到你想要的效果,只需链接目标命令,并执行一次:

${output}=    Execute Command  cd gtms/bin; pwd
Log    ${output}    # will log the output of the executed command(s) - in this case, pwd