basile
basile

Reputation: 51

Telnet : connect, send command and exit in just one line

I try to use telnet in a script (to be use in python program). I want to do the connection, send a command, and exit the connection in juste one line. The command i want to send is to start a program on a remote machine but I d'ont want to wait the end of this program to exit the telnet connection.

I try to do : "echo myCommand | netcat 192.168.1.50 23" but it waits the end of the program.

thanks for your help

Upvotes: 2

Views: 4576

Answers (1)

Ipor Sircer
Ipor Sircer

Reputation: 3141

Use bash builtin tcp socket feature:

echo yourCommand >/dev/tcp/192.168.1.50/23

Upvotes: 6

Related Questions