Automatic command to Telnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatic command to Telnet
# 1  
Old 12-16-2008
Automatic command to Telnet

I'm trying to send a command automatically via Telnet, but without success.
I can do this:
Code:
> telnet 100.100.100.1 8080
Trying 100.100.100.1...
Connected to 100.100.100.1.
Escape character is '^]'.

Whereby I enter "command" and everything works like a charm, but I'd like to do this non-interactively, so I tried this:
Code:
echo command | telnet 100.100.100.1 8080

Doesn't work! What to do?
# 2  
Old 12-16-2008
try:
Code:
(
sleep 1
echo username
sleep 1
echo passwd
sleep 1
echo "your-command"
) | telnet x.x.x.x

# 3  
Old 12-16-2008
Quote:
Originally Posted by ivhb
try:
Code:
(
sleep 1
echo username
sleep 1
echo passwd
sleep 1
echo "your-command"
) | telnet x.x.x.x

This will almost do the trick.
Code:
(
sleep 1
echo "hello"
) | telnet 100.100.100.1 8080

The problem is that sometimes the "hello" is outputted correctly and sometimes I get an empty string. I have no idea why.Smilie
# 4  
Old 12-16-2008
This works perfectly.
Code:
echo "command" | netcat 100.100.100.1 8080

Unfortunately I don't have the luxury to assume that every system that needs this will have netcat. Still in trouble.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Telnet command on AIX

Hello, I need to verify whether I am able to make connection to a remote server from my AIX (os level : 7.1.0.0) host. The host has 2 Alias IP's how can I force an source Alias IP on the telnet command. I tried the below options but none of them worked. Is there any other command that... (6 Replies)
Discussion started by: rosebud123
6 Replies

2. Shell Programming and Scripting

Telnet connection closes before i execute GET command

I tried the below steps for telnet command from a remote server: 1. telnet myservice.com 443 2. GET / HTTP/1.0 3. Press enter key twice Please see the output below: bash-3.2$ hostname remoteserver1 bash-3.2$ telnet myservice.com 443 Trying 191.172.172.133... Connected to... (7 Replies)
Discussion started by: mohtashims
7 Replies

3. Shell Programming and Scripting

If Telnet fail abort other command..??

Hi Team, I my script i telent my node ip and after loging i run some commands...But some time login fail so i want to stop script at that time.. CONFIG_CHNG.sh printf 'Please Input Node ID : ' read node node="$node" #exec > node_log_$node.log 2>&1 #set -x >... (2 Replies)
Discussion started by: Ganesh Mankar
2 Replies

4. Shell Programming and Scripting

Command after telnet

Hello, I'm trying to send a HTTP POST command after doing a telnet to a machine, like below: telnet ip port POST http://ip:port/ HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: text/xml;charset=UTF-8 SOAPAction: "test#Login" Content-Length: 200 Host: ip:port Connection:... (5 Replies)
Discussion started by: rainbow19
5 Replies

5. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

6. Shell Programming and Scripting

Automatic Input to a command

Hi, I have an issue where i run an command in a shell script. command >/dev/null ret=$? echo ret If the command returns an error i'm redirecting it to /dev/null. The prob is if an error comes it expects the user to press return to continue. And hence the return is not echoed. and the end... (4 Replies)
Discussion started by: subhrap.das
4 Replies

7. Shell Programming and Scripting

Telnet to router and execute command

I am trying to write a shell script to execute some commands.. telnet <IP address of the router> wait 10 echo "username" echo "password" sh log exit but i am unable to execute it properly ..please help me .. thanks in advance Sri (1 Reply)
Discussion started by: srikanthus2002
1 Replies

8. UNIX for Dummies Questions & Answers

Automatic logging (capture screen output) of telnet/ssh sessions on a Solaris node

Hi I am working in Solaris 10 and I want to monitor logs for every telnet/ssh session that tries to connect to the server. I need these logs to be generated in a file that I can fetch using ftp. I am a new user and a stepwise detail will be great BR saGGee (3 Replies)
Discussion started by: saggee
3 Replies

9. Shell Programming and Scripting

Telnet in command prompt

Hi, i have typed telnet yahoo.com 80 in command prompt it displays as a blank command prompt page titling as Telnet Yahoo.com Other than that i am not able to get anything. can anyone sort me out the reason for this (12 Replies)
Discussion started by: satheeshkr_cse
12 Replies

10. UNIX for Dummies Questions & Answers

automatic login from windows by a telnet session

Help me please, I wanna know if it's possible to define in windows the option when somebody starts a telnetsession to a unix machine it automatically logs in with the username and password of this user. Or if there is a possibility to set the username and password to an Icon on the users... (3 Replies)
Discussion started by: Herwin
3 Replies
Login or Register to Ask a Question