hii,
i am new to python.. i want to run a batch file on a remote computer by running python script on my computer both in the same network. i am able to run batch file on my computer in python script using subprocess, but not able to access the other computer. So can anybody tell me how to access a different computer or what command is to be used to access different computer whose ip is known to you.. thanks in advance

The best way I've found to do that is to run a ssh server on the remote machine and use the paramiko module. Here is a possible client code

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("IP_ADDRESS", username="USER", password="PASSWORD", allow_agent = False)
i, o, e = ssh.exec_command("cp foo bar") # example command
s = e.read()
if s: # an error occurred
    raise RuntimeError, s
result = o.read()

In windows, I installed copssh on the remote machine (there was a missing dll cygattr1.dll which I found here http://cygwin.cybermirror.org/release/attr/libattr1/libattr1-2.4.43-1.tar.bz2 and copied to the C://program Files/ICW/Bin folder). You must also open the port 22 in the firewall of the remote machine. In linux, there should be an option in your system's control center to run an ssh server.

Paramiko can also transfer files from the client to the server and back.

Also read this post relative to copssh and batch programs http://www.itefix.no/i2/node/12147

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.