"ssh suse-server 'python -V' > python-version.out" not redirecting

Okay, so I have had this problem on openSUSE, and Debian systems now and I am hoping for a little help. I think it has something to do with Python but I couldn't find a proper Python area here.

I am trying to redirect the output of "ssh suse-server 'python -V'" to a file. It seems that no matter what I try, it always prints to stdout. Here is an example of what I am doing.

user@suse-envy4t:~> ssh suse-server 'python -V' > python-version.out 
not a terminal
Python 2.7.3
user@suse-envy4t:~> cat python-version.out
user@suse-envy4t:~> ssh suse-server 'python -V' | tee  python-version.out 
not a terminal
Python 2.7.3
user@suse-envy4t:~> cat python-version.out

Now, I realize that I could just log into the box and do this but I have a lot of systems to do this on. I want to to rap this in a forloop and so I can get a list of what version of python all the boxes have on them... not being able to capture the output of "python -V" is really making this a pain. I hope this is something stupid that I am doing wrong but "ssh suse-server 'cat /etc/issue'" can redirect just fine with >, >>, or tee... so I don't know what I am doing wrong.

Try 2> instead of > .

1 Like

Well there we go!

user@suse-envy4t:~> ssh suse-server 'python -V' 2> python-version.out
user@suse-envy4t:~> cat python-version.out
not a terminal
Python 2.7.3

So, I guess it is not using stdout to report the version.... weird, but it works. Thanks for the help :slight_smile:

Try using -t option - Force pseudo-tty allocation

ssh -t suse-server 'python -V' > python-version.out