Not able to switch to super user in terminal From robot framework

304 views Asked by At
Open Connection    192.***.***.**
Login    ****    *******
Start Command    su hdfs
Execute Command    cd /home/rajesh/hive-latest/
${STDOUT1}    Execute Command    ls -lrt
Log    ${STDOUT1}
Close Connection

*Here i am able to login. after login, not able to switch to super user. without switching to super user, its executing ls -lrt. Please help me with this if anyone knows

1

There are 1 answers

10
Jiri Janous On

This is not how the ssh library works. Have a look at the 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

You can work around this by executing the command as different user, or if possible you can open another connection and login as desired user.

su - <username> -c "<commands>"