- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Telnet Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2003 02:35 PM
тАО08-07-2003 02:35 PM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2003 03:40 PM
тАО08-07-2003 03:40 PM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2003 06:36 PM
тАО08-07-2003 06:36 PM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2003 12:51 AM
тАО08-08-2003 12:51 AM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-11-2003 07:19 AM
тАО08-11-2003 07:19 AM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 03:40 AM
тАО08-21-2003 03:40 AM
Re: Telnet Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2003 02:55 AM
тАО09-11-2003 02:55 AM
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
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-23-2003 01:21 PM
тАО09-23-2003 01:21 PM
Re: Telnet Script
:) gustavo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-23-2003 02:01 PM
тАО09-23-2003 02:01 PM
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!*.