LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-08-2011, 11:04 AM   #1
Nickjpost
LQ Newbie
 
Registered: Dec 2010
Location: Boulder, CO
Distribution: Ubuntu
Posts: 27

Rep: Reputation: 0
Question remote execute exe file from Linux?


Is it possible to start a program in windows from a Linux terminal?

*Let's say this is 'program.exe' & I want to run it and it is in c:\Program Files\program.exe, could I run the .exe from a Linux terminal using that file path, say via samba?

Your insight is very valuable & appreciated!!

Nick
 
Old 09-08-2011, 11:24 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
never tried it but maybe you can install ssh on windows and write a script in linux using ssh keys to ssh into your windows machine and run your program.

i would recommend finding a linux alternative for your windows program and just run it in a bash script.
 
Old 09-08-2011, 11:30 AM   #3
Nickjpost
LQ Newbie
 
Registered: Dec 2010
Location: Boulder, CO
Distribution: Ubuntu
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by schneidz View Post
never tried it but maybe you can install ssh on windows and write a script in linux using ssh keys to ssh into your windows machine and run your program.

i would recommend finding a linux alternative for your windows program and just run it in a bash script.
That is an excellent idea, but I have the Linux machine & a corporate client has a windows machine of which I assist with. Rather than going through all the red tape to accommodate my system I was just wondering if I could just run a program in a given windows file path from my terminal. Thank you for your reply!

(I'm also aware that I could run a vm & remote desktop also, but would prefer the terminal if possible)

Last edited by Nickjpost; 09-08-2011 at 11:31 AM.
 
Old 09-08-2011, 02:51 PM   #4
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Rep: Reputation: 174Reputation: 174
Hi Nick,

A couple of things to point out in reference to your question...

- a Windows executable can not be executed in Linux (some can installed and run under Wine but that is a different situation)
- a Windows program will not run in a terminal (other than command line programs such as dir, chkdsk, mkdir etc.) but those are Windows commands not Linux commands

You say that your are providing assistance to the user of the remote PC. Are you on the same local area network? Here is what I am thinking...

The Remote Desktop Viewer installed for example with Ubuntu Linux can access a shared Windows desktop. If the user's PC is accessible to you and can share the desktop you can connect to it and walk the user through the program steps you are assisting with. If you are truly remote from the user's PC and must connect over the Internet - see if the company has VPN capability (Virtual Private Network) and if they will allow you access.

There are also some web based desktop sharing services although I can not at the moment remember the name of the one I have used. I do recall that I was trying to fix a fax server which had malfunctioned. I remoted to the server and called the tech support for the fax software. The representative had me go to a web site which allowed the representative to remote control my PC which was had a remote session to the server. The support rep found that some sort of configuration file (which no one including me as the admin of the server was supposed to be able to delete) had been deleted. She replaced the missing file and the fax server began to work again. IT Security would have had a fit if they learned that I had basically granted the vendor access to a server in the data center without their OK (after a 6 week study) but the problem got fixed and the clients were happy!

Let us know a little more detail about what you are trying to do. I am sure someone will have some ideas as to how to accomplish your needs.

Ken
 
1 members found this post helpful.
Old 09-08-2011, 02:51 PM   #5
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
probably not, no, but there are remote desktop clients for Linux.
Linux is designed such that almost everything is a client -> server based system (even the gui is an X11 'server' and programs displaying windows are 'clients'), which means you can execute a program stored on one program easily on another.

windows on the other hand doesn't have that level of flexibility, you either export the whole desktop or nothing (well there is a way of telneting into a windows box or perhaps ssh, but don't expect the same flexibility of running gui programs on a windows box via linux that you would between linux machines or from a windows machine running an X server and putty to a linux box)

i would go with either remote desktop or vnc

Last edited by frieza; 09-08-2011 at 02:54 PM.
 
1 members found this post helpful.
Old 09-08-2011, 04:00 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
Might be able to run many of the windows type of deals on wine. There are some native things like wmi for linux but you have to compile it.

Depending on the program telnet or such may work.
 
Old 09-08-2011, 07:36 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,363

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Good advice from all above.
Basically, IF its only a cmd line prog (rare in MS), then ssh'ing in should do it.
Otherwise, you'll need a GUI env eg VNC, VPN, RDP etc.
 
Old 09-08-2011, 07:39 PM   #8
Nickjpost
LQ Newbie
 
Registered: Dec 2010
Location: Boulder, CO
Distribution: Ubuntu
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by taylorkh View Post
Hi Nick,

A couple of things to point out in reference to your question...

- a Windows executable can not be executed in Linux (some can installed and run under Wine but that is a different situation)
- a Windows program will not run in a terminal (other than command line programs such as dir, chkdsk, mkdir etc.) but those are Windows commands not Linux commands

You say that your are providing assistance to the user of the remote PC. Are you on the same local area network? Here is what I am thinking...

The Remote Desktop Viewer installed for example with Ubuntu Linux can access a shared Windows desktop. If the user's PC is accessible to you and can share the desktop you can connect to it and walk the user through the program steps you are assisting with. If you are truly remote from the user's PC and must connect over the Internet - see if the company has VPN capability (Virtual Private Network) and if they will allow you access.

There are also some web based desktop sharing services although I can not at the moment remember the name of the one I have used. I do recall that I was trying to fix a fax server which had malfunctioned. I remoted to the server and called the tech support for the fax software. The representative had me go to a web site which allowed the representative to remote control my PC which was had a remote session to the server. The support rep found that some sort of configuration file (which no one including me as the admin of the server was supposed to be able to delete) had been deleted. She replaced the missing file and the fax server began to work again. IT Security would have had a fit if they learned that I had basically granted the vendor access to a server in the data center without their OK (after a 6 week study) but the problem got fixed and the clients were happy!

Let us know a little more detail about what you are trying to do. I am sure someone will have some ideas as to how to accomplish your needs.

Ken
Ok, so I work for a help desk that supports POS hardware & software. The company I mainly assist has a server that has a windows XP platform with a Unix VM & each POS register has Windows XP as a base to the POS software. Via PC Anywhere, we (the helpdesk) are allowed to remote to that Unix VM to copy & edit files specific to the POS register system. We are able to use samba to transfer said files to & from the registers & I know we are able to use 'net rpc' commands. The issue we face sometimes is that those registers go out of calibration. On each register there is a program that allows the user to attempt calibration accessible on the register touchscreen GUI, though sometimes it is inaccessible if the calibration of the touch screen is severe. I know the windows path for the executable to launch the calibration program. If I recall correctly, in Windows XP, you may run a program from the command line by simply putting the path in quotation; I was wondering, however, if it were possible to execute the program with the windows path using samba or like a "net" command in the terminal. I hope I didn't confuse the issue more with all of that info & let me know if I can clear anything up. Really, the connection is very basic. Think of it as simply a Unix terminal connecting to a Windows XP machine. You only have the textual interface and can only connect to each Windows XP node via samba or use remote commands such as "net rpc" & such.

Last edited by Nickjpost; 09-08-2011 at 07:40 PM. Reason: misspellling
 
Old 09-09-2011, 08:15 AM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
samba wont help because it is emulating a remote filesystem as a local hardrive. so if you try to run a windows pe (*.exe) from a samba share, it will use the local machines cpu/ram/ ... (in this case it will try to run e.g.- iexplorer.exe on the unix machine)

if the windows program is pure cli (meaning that it does not require clicking buttons with the mouse/ touchscreen at all) then something like ssh user@123.456.7.8 cat /etc/fstab will work.

since windows is not meant for automation then i doubt that the program will run from the command-line (heck, you need a keyboard, mouse, monitor to run windows server 2003).

Last edited by schneidz; 09-09-2011 at 08:22 AM.
 
Old 09-09-2011, 08:50 AM   #10
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Rep: Reputation: 174Reputation: 174
Quote:
& let me know if I can clear anything up.
I don't mean to be a stickler for grammar but it would help if you used your Enter key on occasion to separate your thoughts instead of lumping them together in a single run on paragraph. That said...

Try to visualize WHERE the commands you invoke are in fact executed. By that I mean in on what hardware (or virtual hardware) and in what operating system. I believe that will help you to understand what you can and can not run in a terminal.

Lets start at your PC. I am assuming it is a Windows PC. If you invoke PC Anywhere from a menu, shortcut or by issuing the command pcanywhere.exe (or whatever the exact name is) at the command prompt on the PC - the PC Anywhere program executes in Windows on the PC.

Using PC Anywhere you connect to the Unix virtual machine. From now on you do everything within PC Anywhere. If you open a terminal it is opened on the Unix virtual machine. It is as if your keyboard and monitor were plugged into the Unix machine. If you execute "dir" within the terminal you will receive an error. dir is a Windows/DOS command and is not recognized because it is trying to being executed within Linux. If you type "ls" it will work. If the Unix virtual machine has a gui installed and you have permission to it you could perhaps execute "firefox" and the web browser would launch on the Unix machine. You can see the browser but only because PC Anywhere is conveying the Unix screen to you.

And now you "connect" from the Unix machine to one of the POS terminals with Samba. Basically what you are doing is to "map a network drive" in Windows speak. You can see the files on the POS from the Unix machine. However, if you try and run one of the files on the POS by invoking its name in the terminal what will happen? Samba will transfer the file from the POS to the Unix machine. The Unix machine will examine the file and determine that it is not a Unix program and will produce an error just as it did when your typed "dir".

To summarize... Programs are executed on the machine where they are invoked by the operating system running on that machine.

But of course there is an exception to any rule. The exception here is rpc. Remote Procedure Call. rpc lets you package a command, send it to a remote computer, have the remote computer execute the command and return the results to you. By its nature rpc is command and text based. It serves a function where the remote computer does not support a remotely accessible shell interface.

If I am at my PC and I wish to do something on my Linux server I can open a terminal on the PC and execute "ssh taylor10". This establishes a secure connection to my server (taylor10) and the terminal which I am looking at an typing into is in fact running on the server. Any commands entered are terminal are executed on the server. That is the concept of a remotely accessible shell interface. Windows does NOT provide the ability to remotely access the shell on a Windows machine (or if if does I have never figured out how). That is why PC Anywhere like products exist.

So back to rpc. If you look at the documentation for rpc as implemented in Samba http://www.samba.org/samba/docs/man/...etCommand.html you will see that there are a LOT of things you can do on the remote machine. However, all of these commands are strictly text based. You cannot execute firefox by rpc as there is no way for rpc to deliver the firefox gui window back to you. And the commands available by rpc are limited by what is in rpc. You cannot just pick a command available on the POS and send if by rpc.

So thinking out of the box as they say...

Does the calibration program require user input once it is invoked? Does it take a long time to run? If not, perhaps it could be configured to run at boot time. That way if a POS got so far out of calibration that the operator could not invoke the calibration you could remotely reboot the POS and let it fix itself? Or at least start the calibration program so the operator could continue from there?

Ken
 
Old 09-09-2011, 06:31 PM   #11
Nickjpost
LQ Newbie
 
Registered: Dec 2010
Location: Boulder, CO
Distribution: Ubuntu
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by taylorkh View Post
I don't mean to be a stickler for grammar but it would help if you used your Enter key on occasion to separate your thoughts instead of lumping them together in a single run on paragraph. That said...

Try to visualize WHERE the commands you invoke are in fact executed. By that I mean in on what hardware (or virtual hardware) and in what operating system. I believe that will help you to understand what you can and can not run in a terminal.

Lets start at your PC. I am assuming it is a Windows PC. If you invoke PC Anywhere from a menu, shortcut or by issuing the command pcanywhere.exe (or whatever the exact name is) at the command prompt on the PC - the PC Anywhere program executes in Windows on the PC.

Using PC Anywhere you connect to the Unix virtual machine. From now on you do everything within PC Anywhere. If you open a terminal it is opened on the Unix virtual machine. It is as if your keyboard and monitor were plugged into the Unix machine. If you execute "dir" within the terminal you will receive an error. dir is a Windows/DOS command and is not recognized because it is trying to being executed within Linux. If you type "ls" it will work. If the Unix virtual machine has a gui installed and you have permission to it you could perhaps execute "firefox" and the web browser would launch on the Unix machine. You can see the browser but only because PC Anywhere is conveying the Unix screen to you.

And now you "connect" from the Unix machine to one of the POS terminals with Samba. Basically what you are doing is to "map a network drive" in Windows speak. You can see the files on the POS from the Unix machine. However, if you try and run one of the files on the POS by invoking its name in the terminal what will happen? Samba will transfer the file from the POS to the Unix machine. The Unix machine will examine the file and determine that it is not a Unix program and will produce an error just as it did when your typed "dir".

To summarize... Programs are executed on the machine where they are invoked by the operating system running on that machine.

But of course there is an exception to any rule. The exception here is rpc. Remote Procedure Call. rpc lets you package a command, send it to a remote computer, have the remote computer execute the command and return the results to you. By its nature rpc is command and text based. It serves a function where the remote computer does not support a remotely accessible shell interface.

If I am at my PC and I wish to do something on my Linux server I can open a terminal on the PC and execute "ssh taylor10". This establishes a secure connection to my server (taylor10) and the terminal which I am looking at an typing into is in fact running on the server. Any commands entered are terminal are executed on the server. That is the concept of a remotely accessible shell interface. Windows does NOT provide the ability to remotely access the shell on a Windows machine (or if if does I have never figured out how). That is why PC Anywhere like products exist.

So back to rpc. If you look at the documentation for rpc as implemented in Samba http://www.samba.org/samba/docs/man/...etCommand.html you will see that there are a LOT of things you can do on the remote machine. However, all of these commands are strictly text based. You cannot execute firefox by rpc as there is no way for rpc to deliver the firefox gui window back to you. And the commands available by rpc are limited by what is in rpc. You cannot just pick a command available on the POS and send if by rpc.

So thinking out of the box as they say...

Does the calibration program require user input once it is invoked? Does it take a long time to run? If not, perhaps it could be configured to run at boot time. That way if a POS got so far out of calibration that the operator could not invoke the calibration you could remotely reboot the POS and let it fix itself? Or at least start the calibration program so the operator could continue from there?

Ken
Wow, grammar lessons in LinuxQuestions also? That be great!

I just want to initiate the program so the user of the register may continue with the calibration process. It would not be a program I would be able to use from my terminal as you pointed out. Thank you for the link to 'rpc', I believe that will be extremely useful if not for this issue, than many other issues I encounter. Kudos!
 
Old 09-12-2011, 12:24 AM   #12
argon99
Member
 
Registered: Mar 2009
Posts: 37

Rep: Reputation: 16
It is possible to do this with samba. But it takes a little preparation. You need to have a directory that is used only for communications between systems. Something like /runthis. Any file that goes in here is seen by a program you need to write. The program you write watches this directory and executes a program that is associated with the file name. Or you could have directories that are related to programs, such as /runx, /runy, /runwhatever.

For clarification. Let's say the program you need to run to resync the windows POS ( stands for piece of sh-- ) the program name is resync. But you are on a Linux box and can't run it. So you write a program, I suggest using visual basic, that looks at this directory every minute or so. If it finds a file there are a few possible action you can program for.

1: It finds a file and checks it's name. Then it looks up in a table to see if that name is in it's list of allowed names. If it is it deletes the file in the directory and executes the associated windows file. If not it just deletes it

2:The program one writes finds a file in a directory that is only used for communication. This directory is associated with only one program that needs to run so the program that you write deletes the file in the directory and runs the associated program to fix the windows POS.


All of this is very easy to write. It has been at least 25 years ago that I got paid to write windows software but there used to be a windows call to start a program in a "hidden" windows. Meaning that there is nothing on the screen for the loser to see. It's like running something in the background on Linux.

I used to write IVR system and did tricks like this all the time to make windows look like a real OS. If things are running in a hidden window and communicating with files that are in directories it looks like it's multi threaded. I seem to remember that was on "windows for work groups" so I guess that shows how old I am.

The easiest way is to use visual basic. Learn about the timer control and about how to call windows internal commands. Things like the different ways to execute a program from another program. One of the ways will execute it in a hidden window.

Figure this out and make it work and your boss will think you are brilliant. I won't say anything to him.

If you need more help send me a friend request and I will see how I can help.

NOTE:
Well I did a little checking after I posted this and found out that MS has dropped visual basic. Another reason why I think MS is a sucky company. So you are going to need to find something else. I have looked at Lazarus recently and it looks promising. But there are a number of other development tools out there for windows and even ones that will do cross platform stuff, like Lazarus, so do a little googling and you will find out something that will work.

Last edited by argon99; 09-12-2011 at 12:33 AM.
 
Old 09-12-2011, 08:08 AM   #13
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by argon99 View Post
...
For clarification. Let's say the program you need to run to resync the windows POS ( stands for piece of sh-- ) the program name is resync. But you are on a Linux box and can't run it. So you write a program, I suggest using visual basic, that looks at this directory every minute or so. If it finds a file there are a few possible action you can program for.
...
you're basically describing programming a daemon. i'm not sure if programming an automated task in windows is the most fun exercise, especially since most windows programs are gui based and automating mouse movements is pretty tough (my company programmed a remote install process that automatically reboots a machine to login as administrator while the mouse pointer dances across the screen cliking on ok buttons. there is a red border on the screen that reads 'please do not touch keyboard/ mouse' -- seems pretty insecure.).
 
Old 09-13-2011, 11:27 PM   #14
argon99
Member
 
Registered: Mar 2009
Posts: 37

Rep: Reputation: 16
Quote:
Originally Posted by schneidz View Post
you're basically describing programming a daemon. i'm not sure if programming an automated task in windows is the most fun exercise, especially since most windows programs are gui based and automating mouse movements is pretty tough (my company programmed a remote install process that automatically reboots a machine to login as administrator while the mouse pointer dances across the screen cliking on ok buttons. there is a red border on the screen that reads 'please do not touch keyboard/ mouse' -- seems pretty insecure.).
Well I can tell that you haven't done much in the windows world. I have written many programs that run hidden and do exactly as I described. When you say this: " i'm not sure if programming an automated task in windows is the most fun exercise" That tells me you don't know much. It's easy. Before you shoot off your mouth why don't you check out windows API for executing programs. Here is a link I found with about one minutes googling.
For lazy idiots

They used a script to run a program hidden but it did take three people that didn't know what they were talking about before someone that did replied. Now they rest is easier.

But you do demonstrate something that bugs the shit out of me. The net used to have intelligent people on it. Now there are tons of little low lifes that don't know enough to wipe their own A__ telling people that it's to hard to do that sort of thing. Well for them it is so they should just shut the F___ UP and listen to those that know. They might learn something! But then again they probably exhausted their intelligence already so just STFU and leave the learning to others.
 
0 members found this post helpful.
Old 09-14-2011, 04:32 AM   #15
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Reading the initial question: would it be an option to install cygwin on the Windows machine and enable sshd therein? Then you can ssh to the Windows machine and start any application there you like.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wine unable to execute .exe file udaya31 Linux - Software 1 04-09-2011 12:41 PM
How to execute exe file in Linux or Unix Environment? dwarf007 Linux - General 2 02-23-2006 04:29 AM
no such file or directory exists when trying to execute a exe ryedawg Linux - Software 5 12-05-2005 05:42 AM
how to execute a .exe file in linux environment from a c program? aakanksh_c Linux - General 1 09-18-2005 04:26 AM
execute exe file mtitu11 Linux - General 2 09-12-2005 05:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration