Telnetable script on a port


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Telnetable script on a port
# 1  
Old 11-17-2011
Telnetable script on a port

Hi, I have a fairly simple bash script that utilizes 1 argument and runs and display the results of this:
unixCmd ${arg1}

I'd like to run this script on a machine=myserver and attach to port 1234.

When a user on another machine., runs
telnet myserver 1234

Then the user types:
InputItem1

I'd like the response over telnet to be the standard-out of
unixCmd InputItem1

and then the connection closes.

How do I run the script that attaches to a port, listens for input, and send std-out to that telnet connection?
# 2  
Old 11-17-2011
What do you mean by "attach to port"? You want your script to accept incoming connections?

Usually you'd use something like netcat for that.

Remember, only root can listen for connections on ports less than 1024.
# 3  
Old 11-17-2011
Yes, I want the script to accept incoming connections over telnet and take one line of input, process that input, display the script's standard-out over the telnet connection. I still don't see how netcat pipes items into my script AND then pipes back the results.

I really don't want root running this script for security reasons, hence why I chose port 1234 for my example.
# 4  
Old 11-17-2011
Code:
nc -l -e /bin/cat -p 1234

This will cause netcat to run /bin/cat whenever something connects to it, feeding the sockets input into cat, and feeding cat's output back into the socket. Try telnetting to localhost port 9000 1234 and typing lines into it, it'll spit them back to you. ( but be sure to keep a way to kill nc handy as telnet won't know when to quit!).

It can as easily run a shell script as cat.

Last edited by Corona688; 11-21-2011 at 11:58 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script, find the next closed (not in use) port from some port range.

hi, i would like to create a bash script that check which port in my Linux server are closed (not in use) from a specific range, port range (3000-3010). the print output need to be only 1 port, and it will be nice if the output will be saved as a variable or in same file. my code is: ... (2 Replies)
Discussion started by: yossi
2 Replies

2. UNIX for Beginners Questions & Answers

Script for port is open or not

I need a script on which if i will pass the port number and the host name as external parameter then it should respond me if the port is open or not thread moved (0 Replies)
Discussion started by: patitapaban
0 Replies

3. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies

4. Solaris

Cabling and adapters to communicate to service processor serial port from Windows PC with USB port.

Hello, I have an unloaded T5140 machine and want to access the ILOM for the first time and subsequently the network port after that., and then load Solaris 10 the final January 2011 build. The first part is what confuses me -the cabling. I am coming from a Windows machine (w/appropriate... (5 Replies)
Discussion started by: joboy
5 Replies

5. IP Networking

Tcp ip port open but no such process (merged: Release A Port)

i want to kill a tcp connection by killing its pid with netstat -an i got the tcp ip connection on port 5914 but when i type ps -a or ps-e there is not such process running on port 5914 is it possible that because i do not log on with proper user account i can not see that process running? (30 Replies)
Discussion started by: alinamadchian
30 Replies

6. IP Networking

telnet for port 5433 is not working while it works for port 22

Hi, I am trying to set up a dev environment and I have Ubuntu server (10.16.1.92) and a CentOS VM (10.16.3.235) on this. On the CentOS I have a program running on port 5433. Now my problem is that I am unable to telnet this port from another Windows server whereas I can telnet port 22 from... (5 Replies)
Discussion started by: rishav
5 Replies

7. Solaris

How to enable Serial port on ILOM, when Network Port is enabled in parallel

Hi Everyone, In my environment, I have few T5220. On the iLOM Management Card, I have both Network and Serial port are cabled, I don't have any issues while I try to connect using Network Management port, but when I try to connect the serial port for the same server which is actually connected... (3 Replies)
Discussion started by: bobby320
3 Replies

8. Shell Programming and Scripting

Telnet IP and Port Script

Hi, I would like to create a simple script that will telnet a number of IP and Ports one after the other to confirm connectivity to those addresses. I don't need to log on, just output to a file what the response is, i.e Escape Character, connectivity refused etc. Complete newbie to... (6 Replies)
Discussion started by: asou
6 Replies

9. UNIX for Advanced & Expert Users

script to connect to com port

Hi is there any way to connect through com port to using shell script. Thanks in advance. (1 Reply)
Discussion started by: yhacks
1 Replies
Login or Register to Ask a Question