Python : Related to Paramiko - python

I need to run the windows command "XCOPY" on remote machine.
I am using paramiko module to connect to remote machine and run, but I am getting error like invalid path even though the path is valid and same command works if I run on remote command prompt manually. But not possible through paramiko.
Can anybody help?
Regards,
Arun

May be you can get help from:
http://support.microsoft.com/kb/192808
hava a look.

Related

scp command in python script doesn't work

I have a problem for several days. On my Raspberry Pi I go to the terminal for executing the following command:
scp user#subdomain.server.com:/home/path/to/file/test.py /home/pi/update/test.py
It works fine and copies the file from the server without password (because of ssh-keys) to my local machine.
BUT: I have to do exactly the same within a python script:
import os
cmd = 'scp user#subdomain.server.com:/home/path/to/file/test.py /home/pi/update/test.py'
os.system(cmd)
This doesn't work giving an error
ssh: Could not resolve hostname subdomain.server.com: Temporary failure in name resolution
Why do I get this message and especially how can I solve it? Does anyone give an advice, please? I don't understand it ...

Can't run Python Script on remote VM via SSH

I have an Azure VM into which I SSH in. The VM is a W10 host.
I can create files with touch, change directories and so on, but whenever I try to run a python script that is hosted on the VM I get the following error:
The system cannot execute the specified program.
At first glance I thought that there was a problem related to my pyhton alias and the PATH variable, so I decided to use RDP to log into the machine, open a CMD and try the same command, which worked just fine. The python program executed flawlessly.
I used where to find where is my python.exe located at, so whenever I run the script on my remote terminal I can do something like:
C:\Users\User01\AppData\Local\Microsoft\WindowsApps\python.exe test.py
This does result in the same error message as the one stated above.
Can I get some help?
Hi try to execute your command as below.
ssh user#machine python < script.py

Problems with python interpertor after ssh with paramiko into a remote machine

I have a problem with paramiko. For some reason when I use python and paramiko to SSH into a
remote machine which has anaconda installed on I never see the anaconda version of python.
for example
ssh.connect('remote_machine',username='User')
stdin,stdout,stderr = ssh.exec_command("which python")
print stdout.readlines()
which gives me
/usr/bin/python
but when I use regular ssh from terminal to the remote machine I get what I expect
/Users/farside/anaconda/bin
Am I missing something in the way paramiko works ? Maybe there is some problem with the way the bashrc paths are read when using paramiko ssh ?
Thank you!

send argument to command prompt of a remote PC

I am looking for a way to open command prompt of remote PC by using Python. In this process I came only upto open a command prompt from Python and other code is connecting to a windows remote PC but how to combine these two and opening the command prompt of remote PC ?
Simply, I want to send some arguments/commands to remote PC command prompt.
Thank you.
First you need to install SSH on the remote PC's. You test the connection and make sure you are able to login. Google can help if you've not setup ssh before.
Then you can create a python script locally to execute commands over the ssh connection.
You'll probably want to look at either
Fabric -> http://docs.fabfile.org/en/1.8/
or
Paramiko -> http://www.paramiko.org/
Which will be able to run your commands.

How to run a remote Python program from Windows command prompt

I have an app on my website, and I run it with Python from the Windows Command Prompt.
When I try opening it like this,
python http://www.erickwilts.nl/apps/app.py
it says:
python: can't open file 'http://www.erickwilts.nl/apps/app.py': [Errno 22] Invalid argument
Is there a way I can do this?
Since the resource is located on webserver, you must download it first.
You can do it with urllib2
import urllib2
exec(urllib2.urlopen("http://www.erickwilts.nl/apps/app.py").read())
executing scripts like this is really dangerous though.
What I really wanted is to execute the file on the webserver itself. Luckily, I had help from some more experienced guys, who helped me on installing python on the webserver en executing my script from my own computer using ssh.

Categories