MATLAB to TELNET

35 ビュー (過去 30 日間)
Matlab2010
Matlab2010 2012 年 4 月 30 日
コメント済み: Siva Meduri 2024 年 6 月 24 日
hello.
I have a third party program running alongside MATLAB. I wish to send it a message on a specific port.
I can do this through DOS by opening the command window manually and typing
"telnet myPC myPort"
where myPC is my computers name and myPort is a number eg 1000. I can see on the cmd window telnet has connected OK.
I then type
"STOP"
which is the message I wish to send my third party program and I can see in the command window the program stops. great.
When I try and do this in MATLAB i type:
[~, pcName] = system('hostname');
system(['telnet ' pcName ' myPort'])
pause(10); %as connection takes a moment or two
system('STOP')
However, this doesnt work as the connection isnt made and "-1" is returned when I try and telnet.
Any ideas?
(running MATLAB 2010B, win7, 64bit).
thanks!

採用された回答

Matlab2010
Matlab2010 2012 年 5 月 1 日
t = tcpip('123.456.789.123', 8080);
t.write('STOP')
t.close();
Hope this helps. By the way if you want to get a response use:
response = t.read();
(thanks Brent!)
  2 件のコメント
Siva Meduri
Siva Meduri 2024 年 6 月 24 日
I am getting the following error.
The name 'write' is not an accessible property for an instance of class 'TCPIP objects'.
Siva Meduri
Siva Meduri 2024 年 6 月 24 日
I want to connect to from Matlb to remote instument using telnet . I used following code. What is the issue with this code
t = tcpip('123.456.789.123', 8080);
t.write('STOP')
t.close();

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by