user3565150
user3565150

Reputation: 914

Running application on remote server using Python SSH

Is there a possibility to execute an application residing in a remote windows machine like this? The remote host is running a Cygwin SSH server and I am running the below python script from my laptop. The application "xt-ocd.exe" is in the specified path "c/Program Files (x86)/Tensilica/Xtensa OCD Daemon 9.0.3"

ssh.connect('135.24.200.100',username = 'cyg_server',password = 'force')
stdin,stdout,stderr = ssh.exec_command("cd '/cygdrive/c/Program Files     (x86)/Tensilica/Xtensa OCD Daemon 9.0.3';./xt-ocd.exe")

The above script fails to work. I am not sure whether I am on the right track. Please help.

Upvotes: 1

Views: 570

Answers (3)

Cui Heng
Cui Heng

Reputation: 1285

You could also try the full path to launch the program instead of change working directory and then start it.

Upvotes: 0

Serge Ballesta
Serge Ballesta

Reputation: 148965

The line "cd '/cygdrive/c/Program Files (x86)/Tensilica/Xtensa OCD Daemon 9.0.3';./xt-ocd.exe" does not actually represent one single command, but 2 different ones (cd and xt-ocd). That has to be interpreted by a shell.

If the working directory does not matter you could try to use the full path of the executable as proposed by Iskren. But if you really need to set the working directory, you could try :

stdin,stdout,stderr = ssh.exec_command("bash -c \"cd '/cygdrive/c/Program Files (x86)/Tensilica/Xtensa OCD Daemon 9.0.3';./xt-ocd.exe\"")

Upvotes: 1

Iskren
Iskren

Reputation: 1341

I believe that the problem is with the cd you use, it's not a command but a shell function and you don't have a shell. Try executing like this:

ssh.exec_command('/cygdrive/c/Program Files (x86)/Tensilica/Xtensa OCD Daemon 9.0.3/xt-ocd.exe')

Upvotes: 0

Related Questions