Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91568
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-05-31 00:02 -0700 |
| Message-ID | <b92b07c3-6d2a-4fc9-a780-5803b28dadc4@googlegroups.com> (permalink) |
| Subject | Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands |
| From | Pythonista <kukki.kanchana@gmail.com> |
Hello There:
I am using Python 2.7.6 and Paramiko module (on a Linux server) to connect to a Windows server and send some commands and get output. I have a connect function which takes IP, username and password of the remote Windows server and I get an sshobj when that happens. How do I use it to send remote calls is my question?
If it were a local system, I would just say "os.system" but not sure about the remote calls. Can someone help?
My code looks like below: sys.path.append("/home/me/code")
import libs.ssh_connect as ssh
ssh_obj = ssh.new_conn(IP, username, password)
stdin, stdout, stderr = ssh_obj.exec_command("dir") #since the remote system I am SSHing into is Windows.
my "new_conn" looks like this:
import paramiko
def new_conn(IP, username, password):
ssh_obj = paramiko.SSHClient()
ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_conn.connect(IP, username, password), timeout=30)
return ssh_obj
if I replaced "dir" with "ipconfig" it works fine. I wonder how I can make "dir" work - or for that matter.. with "cd /path/to/dir"?
I know for paramiko's ssh connection to work, i need cygwin installed on a Windows. Objective is to run commands remotely from a Linux to a Windows server and then process the output again on Linux server or on Windows itself.
I am confused because, "ipconfig" sent from Linux to Windows using "ssh_obj.exec_command("ipconfig")" works but not "ssh_obj.exec_command("dir")" - tried giving the path like "cd C:\Users\Administrator" for cmd or "cd C:" followed by "cd Users/Administrator" like in Cygwin. Neither of them work.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands Pythonista <kukki.kanchana@gmail.com> - 2015-05-31 00:02 -0700
Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands Peter Otten <__peter__@web.de> - 2015-05-31 14:18 +0200
Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands Pythonista <kukki.kanchana@gmail.com> - 2015-05-31 13:12 -0700
Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-31 20:35 -0400
Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands Pythonista <kukki.kanchana@gmail.com> - 2015-05-31 21:09 -0700
csiph-web