LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2012, 09:59 AM   #1
leamassiot
Member
 
Registered: Dec 2005
Location: France
Distribution: Debian
Posts: 123

Rep: Reputation: 17
Question Running a program on a remote Windows machine via SSH


Hello,

Thank you for reading my post.
My problem is about running a program on a remote Windows machine via SSH.

I have:
(A) - a Windows XP machine running an OpenSSH server.
(B) - a Debian GNU Linux machine.
"test.exe" - a C++ program residing on (A) in the "C:\Program Files\OpenSSH\home\<username>\" directory.

I would like (B) to send the order, through a SSH tunnel, to (A) to run "test.exe".

1) I've tried to execute the following command on (B):
Code:
(B)# ssh <username>@(A) "/home/<username>/test.exe"
I get the following error message:
Code:
/home/<username>/test.exe: error while loading shared libraries: libstdc++-6.dll:
cannot open shared object file: No such file or directory
2) I also tried to run the program locally on (A) via SSH:
Code:
(A)# ssh <username>@localhost "/home/<username>/test.exe"
I get the same error message as in case 1).

3) If I run the program directly on (A) like this:
Code:
(A)# C:\Program Files\OpenSSH\home\<username>\test.exe
The program executes properly.

4) I also tried to first connect to (A) via SSH from (B) and then run the program:
Code:
(B)# ssh <username>@(A)
(A)_via_SSH C:\Program Files\OpenSSH\home\<username># test.exe
It doesn't fail (I get no error message) but does nothing either (the program is supposed to open a file, write something to it and finally close it: nothing happens).

Do you have any idea what can be wrong?
Thank you and best regards.
--
Léa
 
Old 02-21-2012, 10:25 AM   #2
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
don't know what is running on windows box. Something like cygwin with sshd? Native win ssh server?

But what I've seen is that you don't quote this properly:
(A)# C:\Program Files\OpenSSH\home\<username>\test.exe


Change it to
(A)# "C:\Program Files\OpenSSH\home\<username>\test.exe"
mind the blank.
 
Old 02-21-2012, 11:08 AM   #3
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
I just want to confirm: you can run test.exe on the Windows box natively (not through ssh) and it works fine, right? If it doesn't work natively then it won't work over ssh either. The missing shared library error wouldn't be caused by simply trying to run something over ssh I don't think.
 
Old 02-21-2012, 01:16 PM   #4
leamassiot
Member
 
Registered: Dec 2005
Location: France
Distribution: Debian
Posts: 123

Original Poster
Rep: Reputation: 17
Thank you for your answers.
Quote:
@uhelp wrote: don't know what is running on windows box. Something like cygwin with sshd? Native win ssh server?
=> To install "OpenSSH" on (A), I ran the binary installer "OpenSSH_for_Windows_5.6p1-2.exe" which I downloaded from "http://sshwindows.webheat.co.uk/#downloads".

Quote:
@uhelp wrote: But what I've seen is that you don't quote this properly:
(A)# C:\Program Files\OpenSSH\home\<username>\test.exe
Change it to
(A)# "C:\Program Files\OpenSSH\home\<username>\test.exe"
mind the blank.
=> You are right. I'm afraid this is a typo, my apologize :/

Quote:
@R00ts wrote: you can run test.exe on the Windows box natively (not through ssh) and it works fine, right?
=> Right.

Quote:
@R00ts wrote: The missing shared library error wouldn't be caused by simply trying to run something over ssh I don't think.
=> The shared library "libstdc++-6.dll" is not missing from the OS. It can be found in the "C:\MinGW\bin\" directory...

******************************************************************************

Ok. So now, these questions being answered, I made it "partly" work:
I copied "libstdc++-6.dll" (and also "libgcc_s_dw2-1.dll") in the same directory as "test.exe" and I ran the two following commands:
Code:
(A)# ssh <username>@localhost "C:/Program\ Files/OpenSSH/home/<username>/test.exe"
(B)# ssh <username>@(A) "/home/<username>/test.exe"
Both work properly. But, to me - you may contradict me - it's not satisfactory since I had to copy the DLLs next to the executable... but maybe this is "normal".

Note 1: "test.exe" was generated through the "Code::Blocks" IDE, the project being a classical "Console application".

Note 2: We can notice that, when we run a command via SSH, SSH doesn't use the same environment variables as when the command is run natively (in command line directly).

Note 3: Also I have to mention for the sake of completeness that, to make it work natively, I had to add the path "C:\MinGW\bin\" to the OS "Path" environment variable.

Can you help clean/clarify that situation?
Thank you and best regards.
 
Old 02-21-2012, 02:23 PM   #5
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
No, its not normal that you would have to copy the DLLs to be in the same directory as the executable. I've always used cygwin myself and have no experience with MinGW so I'm afraid I can't be of much help to you here. But it sounds like to me that you have to configure your binary and/or library paths in MinGW so that when you run an application, MinGW knows where to search to find the missing DLLs. Taking a brief look, it seems to me that MinGW and OpenSSH are entirely different packages (ie openssh isn't just an add-on package for MinGW). If I'm right, then it makes sense why MinGW native would work fine but OpenSSH would not, since they have no idea about one another.


I think what you need to do is the following:

1) Figure out the paths for binary and shared library files in MinGW
2) Read through the OpenSSH documentation, and figure out how you can set these paths for that package
3) If the paths are identical for MinGW and OpenSSH, you should now be able to SSH into the Windows machine and run your application


If I'm wrong, hopefully someone will come by and correct me. But taking a brief look at your problem that's what I think needs to be done. Good luck, and let us know when you arrive at a solution (and how you arrived at it) for the next person who comes along with a similar problem.
 
Old 02-22-2012, 08:49 AM   #6
leamassiot
Member
 
Registered: Dec 2005
Location: France
Distribution: Debian
Posts: 123

Original Poster
Rep: Reputation: 17
@R00ts - Hello and thank you for your kindness.

I could solve my problem... but to solve it, I had to start a new thread on the "Code::Blocks" forum.
Here is where I've posted my solution:
http://forums.codeblocks.org/index.p...c,15998.0.html
Basically, I had to add two linker options to statically link the DLLs to the executable in the "Code::Blocks" IDE.

Cheers.
--
Léa
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running shell command on remote machine with ssh qrshat Solaris / OpenSolaris 3 08-17-2006 07:32 AM
running X applications on remote machine when logged in via ssh servnov Linux - General 1 08-15-2005 08:53 PM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM
running graphical program on remote machine abd_bela Debian 1 03-17-2005 07:07 AM
running a program through windows machine sooty Linux - General 2 03-10-2003 04:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:37 PM.

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