execute a window application from linux using Python












-1















I'm trying to run a batch file on a windows server. The batch file contains the following code:
"rtmserver 7 5".



which actually runs on windows:



C:Program Files (x86)Video ClarityRTMonitor>rtmserver 7 5


i.e., it opens cmd and runs this command that starts the windows application properly



in the same way:
If I double click the batch file it opens THIS software that I can use it.
Id I drag and drop it to cmd it runs also OK (C:Usersuser>C:UsersuserDesktopClarityCommandsRTMServer.bat.lnk)



BUT, If I try to open it from SSH connection that is run on other Linux machine that uses paramiko and connects to this windows, It fails:



class SSH_Connection(object):
def __init__(self, LOCAL_IP, username, password):
self.LOCAL_IP = LOCAL_IP
self.username = username
self.password = password
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(self.LOCAL_IP, username=self.username, password=self.password)
self.sftp = self.client.open_sftp()
def std(self, message):
self.message = message
_in, out, err = self.client.exec_command(self.message)
exitcode = out.channel.recv_exit_status()
stdout = ''.join(out.read())
stderr = ''.join(err.read())
return stdout, stderr, exitcode

class Clarity(SSH_Connection):
pass

clarity = Clarity(LOCAL_IP='172.24.11.57', username='user', password='user')


NOW, when I'm trying to call the batch file to execute the opening for this application by the following paramiko and SFTP options given by Python:



clarity.std('"C:Program Files (x86)Video ClarityRTMonitorRTMServer.bat"')


This returns the following:



('rnuser@CV-S2042-RTM C:\Users\user>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)


So, my Linux machine fails to open this application remotly



Any thoughts how to solve this?










share|improve this question























  • So a path to rtmserver is in PATH environment variable of your local Windows account?

    – Martin Prikryl
    Nov 14 '18 at 10:44











  • Are you logging into SSH using the same account as you use locally on Windows?

    – Martin Prikryl
    Nov 14 '18 at 10:45











  • You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

    – lit
    Nov 14 '18 at 13:30











  • Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

    – Squashman
    Nov 14 '18 at 13:33











  • @Squashman, how?

    – Itaybz
    Nov 17 '18 at 18:29


















-1















I'm trying to run a batch file on a windows server. The batch file contains the following code:
"rtmserver 7 5".



which actually runs on windows:



C:Program Files (x86)Video ClarityRTMonitor>rtmserver 7 5


i.e., it opens cmd and runs this command that starts the windows application properly



in the same way:
If I double click the batch file it opens THIS software that I can use it.
Id I drag and drop it to cmd it runs also OK (C:Usersuser>C:UsersuserDesktopClarityCommandsRTMServer.bat.lnk)



BUT, If I try to open it from SSH connection that is run on other Linux machine that uses paramiko and connects to this windows, It fails:



class SSH_Connection(object):
def __init__(self, LOCAL_IP, username, password):
self.LOCAL_IP = LOCAL_IP
self.username = username
self.password = password
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(self.LOCAL_IP, username=self.username, password=self.password)
self.sftp = self.client.open_sftp()
def std(self, message):
self.message = message
_in, out, err = self.client.exec_command(self.message)
exitcode = out.channel.recv_exit_status()
stdout = ''.join(out.read())
stderr = ''.join(err.read())
return stdout, stderr, exitcode

class Clarity(SSH_Connection):
pass

clarity = Clarity(LOCAL_IP='172.24.11.57', username='user', password='user')


NOW, when I'm trying to call the batch file to execute the opening for this application by the following paramiko and SFTP options given by Python:



clarity.std('"C:Program Files (x86)Video ClarityRTMonitorRTMServer.bat"')


This returns the following:



('rnuser@CV-S2042-RTM C:\Users\user>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)


So, my Linux machine fails to open this application remotly



Any thoughts how to solve this?










share|improve this question























  • So a path to rtmserver is in PATH environment variable of your local Windows account?

    – Martin Prikryl
    Nov 14 '18 at 10:44











  • Are you logging into SSH using the same account as you use locally on Windows?

    – Martin Prikryl
    Nov 14 '18 at 10:45











  • You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

    – lit
    Nov 14 '18 at 13:30











  • Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

    – Squashman
    Nov 14 '18 at 13:33











  • @Squashman, how?

    – Itaybz
    Nov 17 '18 at 18:29
















-1












-1








-1


1






I'm trying to run a batch file on a windows server. The batch file contains the following code:
"rtmserver 7 5".



which actually runs on windows:



C:Program Files (x86)Video ClarityRTMonitor>rtmserver 7 5


i.e., it opens cmd and runs this command that starts the windows application properly



in the same way:
If I double click the batch file it opens THIS software that I can use it.
Id I drag and drop it to cmd it runs also OK (C:Usersuser>C:UsersuserDesktopClarityCommandsRTMServer.bat.lnk)



BUT, If I try to open it from SSH connection that is run on other Linux machine that uses paramiko and connects to this windows, It fails:



class SSH_Connection(object):
def __init__(self, LOCAL_IP, username, password):
self.LOCAL_IP = LOCAL_IP
self.username = username
self.password = password
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(self.LOCAL_IP, username=self.username, password=self.password)
self.sftp = self.client.open_sftp()
def std(self, message):
self.message = message
_in, out, err = self.client.exec_command(self.message)
exitcode = out.channel.recv_exit_status()
stdout = ''.join(out.read())
stderr = ''.join(err.read())
return stdout, stderr, exitcode

class Clarity(SSH_Connection):
pass

clarity = Clarity(LOCAL_IP='172.24.11.57', username='user', password='user')


NOW, when I'm trying to call the batch file to execute the opening for this application by the following paramiko and SFTP options given by Python:



clarity.std('"C:Program Files (x86)Video ClarityRTMonitorRTMServer.bat"')


This returns the following:



('rnuser@CV-S2042-RTM C:\Users\user>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)


So, my Linux machine fails to open this application remotly



Any thoughts how to solve this?










share|improve this question














I'm trying to run a batch file on a windows server. The batch file contains the following code:
"rtmserver 7 5".



which actually runs on windows:



C:Program Files (x86)Video ClarityRTMonitor>rtmserver 7 5


i.e., it opens cmd and runs this command that starts the windows application properly



in the same way:
If I double click the batch file it opens THIS software that I can use it.
Id I drag and drop it to cmd it runs also OK (C:Usersuser>C:UsersuserDesktopClarityCommandsRTMServer.bat.lnk)



BUT, If I try to open it from SSH connection that is run on other Linux machine that uses paramiko and connects to this windows, It fails:



class SSH_Connection(object):
def __init__(self, LOCAL_IP, username, password):
self.LOCAL_IP = LOCAL_IP
self.username = username
self.password = password
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(self.LOCAL_IP, username=self.username, password=self.password)
self.sftp = self.client.open_sftp()
def std(self, message):
self.message = message
_in, out, err = self.client.exec_command(self.message)
exitcode = out.channel.recv_exit_status()
stdout = ''.join(out.read())
stderr = ''.join(err.read())
return stdout, stderr, exitcode

class Clarity(SSH_Connection):
pass

clarity = Clarity(LOCAL_IP='172.24.11.57', username='user', password='user')


NOW, when I'm trying to call the batch file to execute the opening for this application by the following paramiko and SFTP options given by Python:



clarity.std('"C:Program Files (x86)Video ClarityRTMonitorRTMServer.bat"')


This returns the following:



('rnuser@CV-S2042-RTM C:\Users\user>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)


So, my Linux machine fails to open this application remotly



Any thoughts how to solve this?







linux windows batch-file cmd paramiko






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 10:30









ItaybzItaybz

134




134













  • So a path to rtmserver is in PATH environment variable of your local Windows account?

    – Martin Prikryl
    Nov 14 '18 at 10:44











  • Are you logging into SSH using the same account as you use locally on Windows?

    – Martin Prikryl
    Nov 14 '18 at 10:45











  • You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

    – lit
    Nov 14 '18 at 13:30











  • Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

    – Squashman
    Nov 14 '18 at 13:33











  • @Squashman, how?

    – Itaybz
    Nov 17 '18 at 18:29





















  • So a path to rtmserver is in PATH environment variable of your local Windows account?

    – Martin Prikryl
    Nov 14 '18 at 10:44











  • Are you logging into SSH using the same account as you use locally on Windows?

    – Martin Prikryl
    Nov 14 '18 at 10:45











  • You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

    – lit
    Nov 14 '18 at 13:30











  • Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

    – Squashman
    Nov 14 '18 at 13:33











  • @Squashman, how?

    – Itaybz
    Nov 17 '18 at 18:29



















So a path to rtmserver is in PATH environment variable of your local Windows account?

– Martin Prikryl
Nov 14 '18 at 10:44





So a path to rtmserver is in PATH environment variable of your local Windows account?

– Martin Prikryl
Nov 14 '18 at 10:44













Are you logging into SSH using the same account as you use locally on Windows?

– Martin Prikryl
Nov 14 '18 at 10:45





Are you logging into SSH using the same account as you use locally on Windows?

– Martin Prikryl
Nov 14 '18 at 10:45













You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

– lit
Nov 14 '18 at 13:30





You may need to specify a fully qualified path to the rtmserver.bat script. If that is not enough, using cmd.exe /C "C:Program Files (x86)Video ClarityRTMonitor>rtmserver" 7 5 may be needed.

– lit
Nov 14 '18 at 13:30













Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

– Squashman
Nov 14 '18 at 13:33





Why wouldn't you just execute rtmserver directly instead of putting it in a batch file?

– Squashman
Nov 14 '18 at 13:33













@Squashman, how?

– Itaybz
Nov 17 '18 at 18:29







@Squashman, how?

– Itaybz
Nov 17 '18 at 18:29














1 Answer
1






active

oldest

votes


















0














So, looking at your output:




('rnuser@CV-S2042-RTM C:Usersuser>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)




This appears that you are trying to run rtmserver from C:Usersuser



Unless the path to rtmserver exists in your PATH environment variable, the system will assume that the executable is in the current working directory (which is C:Usersuser)



Adding C:Program Files (x86)Video ClarityRTMonitor to your PATH environment variable should fix this.






share|improve this answer
























  • True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

    – Martin Prikryl
    Nov 14 '18 at 11:39













  • Do you need quotes because of the spaces in pathname?

    – Marichyasana
    Nov 14 '18 at 11:51











  • Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

    – Mike Oldfield
    Nov 14 '18 at 11:56













  • @marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

    – Itaybz
    Nov 17 '18 at 18:40













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298036%2fexecute-a-window-application-from-linux-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














So, looking at your output:




('rnuser@CV-S2042-RTM C:Usersuser>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)




This appears that you are trying to run rtmserver from C:Usersuser



Unless the path to rtmserver exists in your PATH environment variable, the system will assume that the executable is in the current working directory (which is C:Usersuser)



Adding C:Program Files (x86)Video ClarityRTMonitor to your PATH environment variable should fix this.






share|improve this answer
























  • True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

    – Martin Prikryl
    Nov 14 '18 at 11:39













  • Do you need quotes because of the spaces in pathname?

    – Marichyasana
    Nov 14 '18 at 11:51











  • Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

    – Mike Oldfield
    Nov 14 '18 at 11:56













  • @marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

    – Itaybz
    Nov 17 '18 at 18:40


















0














So, looking at your output:




('rnuser@CV-S2042-RTM C:Usersuser>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)




This appears that you are trying to run rtmserver from C:Usersuser



Unless the path to rtmserver exists in your PATH environment variable, the system will assume that the executable is in the current working directory (which is C:Usersuser)



Adding C:Program Files (x86)Video ClarityRTMonitor to your PATH environment variable should fix this.






share|improve this answer
























  • True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

    – Martin Prikryl
    Nov 14 '18 at 11:39













  • Do you need quotes because of the spaces in pathname?

    – Marichyasana
    Nov 14 '18 at 11:51











  • Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

    – Mike Oldfield
    Nov 14 '18 at 11:56













  • @marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

    – Itaybz
    Nov 17 '18 at 18:40
















0












0








0







So, looking at your output:




('rnuser@CV-S2042-RTM C:Usersuser>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)




This appears that you are trying to run rtmserver from C:Usersuser



Unless the path to rtmserver exists in your PATH environment variable, the system will assume that the executable is in the current working directory (which is C:Usersuser)



Adding C:Program Files (x86)Video ClarityRTMonitor to your PATH environment variable should fix this.






share|improve this answer













So, looking at your output:




('rnuser@CV-S2042-RTM C:Usersuser>rtmserver 7 5 rn',
"'rtmserver' is not recognized as an internal or external command,rnoperable program or batch file.rn",
1)




This appears that you are trying to run rtmserver from C:Usersuser



Unless the path to rtmserver exists in your PATH environment variable, the system will assume that the executable is in the current working directory (which is C:Usersuser)



Adding C:Program Files (x86)Video ClarityRTMonitor to your PATH environment variable should fix this.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 11:34









Mike OldfieldMike Oldfield

1




1













  • True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

    – Martin Prikryl
    Nov 14 '18 at 11:39













  • Do you need quotes because of the spaces in pathname?

    – Marichyasana
    Nov 14 '18 at 11:51











  • Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

    – Mike Oldfield
    Nov 14 '18 at 11:56













  • @marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

    – Itaybz
    Nov 17 '18 at 18:40





















  • True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

    – Martin Prikryl
    Nov 14 '18 at 11:39













  • Do you need quotes because of the spaces in pathname?

    – Marichyasana
    Nov 14 '18 at 11:51











  • Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

    – Mike Oldfield
    Nov 14 '18 at 11:56













  • @marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

    – Itaybz
    Nov 17 '18 at 18:40



















True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

– Martin Prikryl
Nov 14 '18 at 11:39







True. But OP claims that the batch file works, when executed locally. So I assume that the path to rtmserver must be present in PATH variable, at least in some situations.

– Martin Prikryl
Nov 14 '18 at 11:39















Do you need quotes because of the spaces in pathname?

– Marichyasana
Nov 14 '18 at 11:51





Do you need quotes because of the spaces in pathname?

– Marichyasana
Nov 14 '18 at 11:51













Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

– Mike Oldfield
Nov 14 '18 at 11:56







Normally a path in the PATH variable should not need quotes. They are separated with the ; character rather than a space. I wonder if this may be a difference in whether it is defined in the user PATH or the system PATH. Is the batch being executed by the same user that can double-click-to-run?

– Mike Oldfield
Nov 14 '18 at 11:56















@marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

– Itaybz
Nov 17 '18 at 18:40







@marti, the PATh variable is there:C:program files (x86)video clarityRTMonitor

– Itaybz
Nov 17 '18 at 18:40






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298036%2fexecute-a-window-application-from-linux-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma