Using MATLAB Script To Run remote Linux Program via Telnet

3 vues (au cours des 30 derniers jours)
Sy
Sy le 14 Fév 2013
I have a C program on Linux Fedora 14, and now I am trying to remotely running it from a different PC using MATLAB via telnet. But right now all I can do is calling putty from matlab to access Linux terminal, and run the program through this remote terminal. But it is useless for me because I can't automate the MATLAB script to call the program repeatedly.
To illustrate my situation. Say I have a program Hello as following:
void main (int argc, char* argv){
if(argc > 0){
printf("Hello %s \n", argv);
printf("result is %d", argc++);
}
return;
}
I want to have a MATLAB script that can run this program from a remote PC and input a name and read the result multiple times. But now all I have is calling
system('C:\Putty\putty.exe <ip_address> -username -password')
from matlab and get the remote terminal on Linux, then manually run
./hello name.
How can I run the whole program from matlab directly through telnet? And get the result?
Thanks.

Réponse acceptée

Jason Ross
Jason Ross le 14 Fév 2013
Modifié(e) : Jason Ross le 14 Fév 2013
You might want to try uing "plink" rather than PuTTY. It's part of the PuTTY suite, so you likely have it already since you've installed PuTTY.
Section 7.3 is pretty close to what you are trying to do.
As for getting the result, the program can output to the terminal and you can use
[status,result] = system(<system command here>)
to get it. Or, if you have a common filesystem between the two systems, you could output it there and then retrieve it.
  5 commentaires
Jason Ross
Jason Ross le 15 Fév 2013
Well, if there is a specific error condition for it, I'd guess so. :)
I haven't used telnet in a while -- does it challenge you for a password? In general, I'd say ssh is probably the more portable and maintainable choice, anyway -- telnet and rsh are still useful tools, but the world has largely moved to ssh for any number of reasons (secure, traceable, configurable, standard, debuggable, etc)
Sy
Sy le 15 Fév 2013
I see, thank you.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 14 Fév 2013
You are probably using the wrong program for your needs. See

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by