- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- Telnet Script
-
-
Categories
- Topics
- Hybrid IT with Cloud
- Mobile & IoT
- IT for Data & Analytics
- Transformation
- Strategy and Technology
- Products
- Cloud
- Integrated Systems
- Networking
- Servers and Operating Systems
- Services
- Storage
- Company
- Events
- Partner Solutions and Certifications
- Welcome
- Welcome
- Announcements
- Tips and Tricks
- Feedback
-
Blogs
- Alliances
- Around the Storage Block
- Behind the scenes @ Labs
- Converged Data Center Infrastructure
- Digital Transformation
- Grounded in the Cloud
- HPE Careers
- HPE Storage Tech Insiders
- Infrastructure Insights
- Inspiring Progress
- Internet of Things (IoT)
- My Learning Certification
- Networking
- OEM Solutions
- Servers: The Right Compute
- Telecom IQ
- Transforming IT
-
Quick Links
- Community
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Contact
- Email us
- Tell us what you think
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Enterprise.nxt
- Marketplace
- Aruba Airheads Community
-
Categories
-
Forums
-
Blogs
-
InformationEnglish
Telnet Script
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-07-2003 02:35 PM
08-07-2003 02:35 PM
Telnet Script
Telnet Script
(Note: the processor one the linux machine is very slow so running any language fancier the C will not work)
Any suggestion are greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-07-2003 03:40 PM
08-07-2003 03:40 PM
Re: Telnet Script
Re: Telnet Script
http://expect.nist.gov/#windows or
http://bmrc.berkeley.edu/people/chaffee/expectnt.html
and then use this script
+++++++++++++++++
#!/usr/bin/expect -f
#
# This script telnets to a specific host as a specifc user and sets the required
# environment variables.
#Change default timeout
set timeout 100
#Variables. Change as necessary
set TERM xterm ;#default TERM
set prompt "(%|#|\\$) $" ;# default prompt
catch {set prompt $env(EXPECT_PROMPT)}
#Host Name
set SERVER "[lrange $argv 0 0]"
set USER "[lrange $argv 1 1]"
set PASSWD "[lrange $argv 2 2]"
#Command List
set COMMANDS "[lrange $argv 3 $argc]"
#Spawn Telnet
spawn telnet
expect "telnet> "
#Initialise a Connection
send "open $SERVER\r"
#Login to the Server
expect {
-re "Connection timed out" {
send_user "Unable to connect to $host. Exiting..."
exit 1
}
timeout {
send_user "Timed out connecting to $host. Exiting..."
exit 1
}
"login* "
}
send "$USER\r"
expect "Password:*"
send "$PASSWD\r"
expect {
-re "Login incorrect*" {
send_user "Looks like the password is wrong. Spawning a shell..."
interact
exit 1
}
-re $prompt
}
#loop through arguments
foreach command $COMMANDS {
send "$command\r"
expect -re $prompt
}
send_user "Expect Scripts Ends. Good Bye!!!\n"
+++++++++++++++++
run this script as
scriptname server name password command(s)
hth
-balaji
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-07-2003 06:36 PM
08-07-2003 06:36 PM
Re: Telnet Script
Re: Telnet Script
In a file (name ToDo) put all commands you want to pass in the telnet session.
...
In an other file "ScriptFile"
telnet @IP < ToDo
And execute ScriptFile
The password goes across the network clear text, so whats the big deal about having it in an open file.
Openssh would be a better alternative.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-08-2003 12:51 AM
08-08-2003 12:51 AM
Re: Telnet Script
Re: Telnet Script
You could use sftp from putty on the XP
this is can be downloaded from many places
in the Telnet category at Tucows.com. Tucows
or http://www.putty.nl/download.html
The stting up of the ssh (putty)is not that tedious and once you have your private/public key set up right it would be more secure
hope this track will be of use
whatever keep us informed.
Jean-Pierre
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-11-2003 07:19 AM
08-11-2003 07:19 AM
Re: Telnet Script
Re: Telnet Script
telnet 192.168.0.58 < toDo.txt
and all that was returned was
Welcome to Microsoft Telnet Client
Excape Character is 'CTRL+]'
Yet when I go telnet 192.168.0.58 I got the login prompt from my linux machine. I did have the 'telnet 192.168.0.68 < toDo.txt' originally in a .bat file but when nothing happend I tried typing it into the command prompt manually instead.
Any suggestions are greatly appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-21-2003 03:40 AM
08-21-2003 03:40 AM
Re: Telnet Script
Re: Telnet Script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-11-2003 02:55 AM
09-11-2003 02:55 AM
Re: Telnet Script
Re: Telnet Script
If you ty to redirect its stdin or stdout, it will not work, it will die. That's how telnet works :(
BUT, take a look at:
Telnet Scripting Tool v.1.0
by Albert Yale ay@aci.qc.ca http://ay.home.ml.org/
I think that homepage is not functional anymore, but it can be found literally anywhere on the Net (try Google, you find it).
It lets you write a very, very, very simple script, in which you put commands to be executed on the remote system, and stores output in a text file. After it sends a command, it waits for a specified answer, so the speed of the remote system is not relevant.
Can be envoked from .BAT, and Windows Scripting Host Files (.VBs, .JS)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2003 01:21 PM
09-23-2003 01:21 PM
Re: Telnet Script
Re: Telnet Script
:) gustavo
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2003 02:01 PM
09-23-2003 02:01 PM
Re: Telnet Script
Re: Telnet Script
(
sleep 3 # This is to wait for the connection to occur
echo username
sleep 2 # Username will go in Login: prompt, this will wait a while for Passwrod:
echo password
sleep 2 # finish the login, get a prompt
echo "CommandToExecute; exit"
sleep XX # wait for command to complete, then exit.
) | telnet HOST
Now, whilst this will work in simple situations, it doesn't have any accountability with regards to network degredation, or server load. Using Expect takes these into consideration, simply by waiting for expected text.
The above example just takes 'guesses', in other words *IS NOT RELIABLE!*.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2018 Hewlett Packard Enterprise Development LP