Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-26-2007, 11:29 AM   #1
LQ Newbie
Registered: Mar 2005
Posts: 12

Rep: Reputation: 0
telnet script

Hi folks,

just by searching here I've found this script, which automates a telnet connection to a host:



( echo open ${host} ${port}
sleep 1
echo -e "\r"
sleep 1
echo ${pass}
sleep 1
echo -e "\r"
sleep 1
echo ${cmd1}
sleep 1
echo -e "\r"
sleep 1
echo ${cmd2}
sleep 1
echo -e "\r"
sleep 1
echo ${cmd3}
sleep 1
echo -e "\r"
sleep 1
echo exit ) | telnet host

I have also checked and it runs , but I donīt understand how , I mean what I see are some commands which output goes to the telnet application through a pipe, but when I run the script it seems as the telnet was executing first instead of the group of the commands before te pipe (echo and sleep commands).

Any feedback about this will be welcome.

Thanks in advance.

Old 10-26-2007, 04:33 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,053
Blog Entries: 14

Rep: Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226
You misunderstand how a pipeline works. While it does in fact execute what is done on the left side of the pipe first it won't show it to you because the pipe redirects all output of the left side into the right side. From your viewpoint what is being executed is the right side as if the left side was being used as part of its input line.

Similarly if you're in a directory and do "ls |sort" you won't see the original ls output - you'll just see the sorted output. If it didn't work that way you'd see the unsorted output and then the sorted output which would not be very useful.
Old 10-27-2007, 07:52 AM   #3
LQ Newbie
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0

firstly thanks for your reply. You're right I was confused about how pipeline works so now it's a little bit more clear.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Telnet in a script, want to save Telnet output, howtodothis??? anil3 Linux - Software 2 03-08-2006 05:01 PM
Telnet script pirra Programming 1 12-29-2004 04:04 PM
Telnet script?? mike400hp Linux - Newbie 6 08-22-2003 04:41 PM
telnet script tn1681 Linux - General 3 07-25-2002 11:09 PM
telnet script tn1681 Programming 2 07-24-2002 09:47 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration