0

Does anyone know why a ssh command output to the screen and to a variable is not the same? my meaning is when the command output direct to the screen it's and when i save it to a variable and then print the variable is not the same output:

to the screen:

s.sendline ('uptime')
s.prompt()
print s.before
s.logout(

output:

uptime
 09:52:40 up 170 days, 16:20,  4 users,  load average: 0.02, 0.02, 0.00

to a variable:

running = s.sendline ('uptime')
print (running)

output:

7

i'm really don't understand where the '7' comes from and why i got to different outputs?

Thanks for the help.

1

1 Answer 1

1

From the docs:

sendline(s='')

Wraps send(), sending string s to child process, with os.linesep automatically appended. Returns number of bytes written

Sign up to request clarification or add additional context in comments.

4 Comments

OK, sow how can i get the output variable and use if for other needs?
You could redirect stdout, what do you want to do with the output?
The output will be in s.before, as in your previous example.
lets say that the output it's a name of a direcotry and then i would like to enter to that directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.