Is there any way i can get a login shell in ruby using net-ssh?
Is that even possible?
By login shell i mean the ones the source /etc/profile..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Net-SSH is too low level to simply provide this up front (the way it is now, anyways). You can check out Net-SSH-Shell which builds upon Net-SSH to add login shell functionality: https://github.com/mitchellh/net-ssh-shell
The implementation is solid and works, however I found its not too useful since you can’t specifically extract things like stderr or exit status because the commands run in a sub-shell, so you can only get stdout. The net-ssh-shell library uses some hacks to get the exit status.
I’ve needed a “login shell” for my own Ruby projects and to do this I’ve generally executed things directly into the shell using the following code:
With this solution you still don’t get exit status or stderr of commands run into the login shell, but at least the commands are executed in that context.
I hope this helps.