Using MATLAB Script To Run remote Linux Program via Telnet
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Jason Ross
2013-2-14
编辑:Jason Ross
2013-2-14
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 个评论
Jason Ross
2013-2-15
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)
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!