Visit Our UNIX and Linux User Community


Telnet non interactive


 
Thread Tools Search this Thread
Operating Systems AIX Telnet non interactive
# 1  
Old 10-20-2009
Telnet non interactive

Dear all,

I need to have shell script which does telnet to another machine with non interactive way like what we do using ftp.

Thanks,
Shahnaz.
# 2  
Old 10-20-2009
This is asked quite often - please use the search function of the forum or have a look at expect.
# 3  
Old 10-20-2009
Thanks indeed for that link.

but it has the following line

Code:
# Assume $remote_server, $my_user_id, $my_password, and $my_command were read in earlier 
  # in the script.  # Open a telnet session to a remote server, and wait for a username prompt.
  spawn telnet $remote_server
  expect "username:"  # Send the username, and then wait for a password prompt.
  send "$my_user_id\r"
  expect "password:"  # Send the password, and then wait for a shell prompt.
  send "$my_password\r"
  expect "%"  # Send the prebuilt command, and then wait for another shell prompt.
  send "$my_command\r"
  expect "%"  # Capture the results of the command into a variable. This can be displayed, or written to disk.
  set results $expect_out(buffer)  # Exit the telnet session, and wait for a special end-of-file character.
  send "exit\r"
  expect eof

I didn't see this script working, Can you please say what needs to be done to make telnet interactive.
I search lot of sites through search engine but none gave exact information.

Thanks,
Shahnaz
# 4  
Old 10-20-2009
The command is "interact" (very non-intuitive, right?)

See my A Y2K Problem solved with Expect for an example.

Previous Thread | Next Thread
Test Your Knowledge in Computers #867
Difficulty: Medium
John McDonald developed Lisp in 1958 while he was at the Massachusetts Institute of Technology (MIT).
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference Between Krb5-telnet And Ekrb5-telnet

Hi, I want to know the difference between these two services. Both are under xinetd. Both are used for enabling and disabling Telnet service. So, can somebody please explain me the difference between the two ? Thanks in advance :) (0 Replies)
Discussion started by: kashifsd17
0 Replies

2. UNIX for Dummies Questions & Answers

Automatically login in the telnet from present telnet

Hi, I was writing one script which includes to switch to the another telnet automatically from the present telnet server. I was using rlogin but firstly it takes the same user name of the present telnet and secondly it is prompting for the password. But i want to switch to the another telnet... (2 Replies)
Discussion started by: Prateek
2 Replies

3. Shell Programming and Scripting

Interactive script

Greetings gurus I have this simple scripts #!/bin/bash find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" > data_schema find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" >> data_schema <data.schema awk '{print NR, "inVol=" $0, "setDt=4000",... (1 Reply)
Discussion started by: Marjan
1 Replies

4. Shell Programming and Scripting

non interactive vim

I wanna edit a file non-interactively using vim editor The file contains a line: ACTIVATIONCODE= I have a variable called ACT. I want to edit the file non-interactively using vim such that the concerned line is converted to: ACTIVATIONCODE=contents of the variable ACT ---------- Post... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

5. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

6. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

7. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

8. Shell Programming and Scripting

Interactive menu

Hi ,some time ago i did an interactive menu based on eval function for navigation , one of the post remind me it. I think it could be handy for others. #!/usr/bin/ksh keyRead () { tput smso echo "Enter option." tput rmso oldstty=$(stty -g) stty -icanon -echo min 1 time 1 Answer=$(dd... (0 Replies)
Discussion started by: Klashxx
0 Replies

9. UNIX for Dummies Questions & Answers

Interactive Mode?

:confused: Can anyone please tell me how to get into Interactive Mode? (2 Replies)
Discussion started by: Nomad
2 Replies

10. Shell Programming and Scripting

Interactive String

I intend to write a script, where the user will supply the name of the specific string that script should work on. The first question is how do I accept the string, i.e interactively? and the second question how would the string be refrenced ? Thanks in advance, Odogbolu98 :( (3 Replies)
Discussion started by: odogbolu98
3 Replies

Featured Tech Videos