how to use, "sudo su - user" in SSHLibrary

1,270 views
Skip to first unread message

Dev S

unread,
Jan 25, 2015, 8:10:25 AM1/25/15
to robotframe...@googlegroups.com
Hi,

I am getting stuck in SSHLibrary, if anybody any have an idea, please share with me.

Issue - Not able change the user on the same server; using sudo su - user

login to the server and than have to switch user " sudo su - user" 

code - 
    Open Connection    localhost
    ${output}=    Login    mainuser    userpass
    Should Contain    ${output}    mainuser@host1:~$
    ${stdout1}=    Execute Command    sudo su - user2; xxxxxx
    ${stdout2}=    Execute Command    whoami
    Should Be Equal    ${stdout1}    ${stdout2}
    Close Connection

outpur :-

20150125 18:26:01.024 :  INFO : Executing command 'sudo su - user2; xxxxxx'.
20150125 18:26:01.067 :  INFO : Command exited with return code 127.


Thanks in advance.


Jerry S.

unread,
Jan 27, 2015, 5:45:00 PM1/27/15
to robotframe...@googlegroups.com
exit code 127 is "command not found".  What happens if you put the full path to your sudo and "xxxxx"?

jer

Sachin Nikam

unread,
Jan 28, 2015, 11:25:00 PM1/28/15
to robotframe...@googlegroups.com
Hi,

Your getting this problem because 'Execute Command' always uses new shell, so for the next command new shell gets used due to which your execute command now working.

If you want to execute all your commands in same shell then use write keyword.

You can get more info here:

Thanks & Regards,
Sachin Nikam
Reply all
Reply to author
Forward
0 new messages