- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to write script for telnet session
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
Forums
Discussions
Discussions
Discussions
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
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
06-29-2004 08:54 PM
06-29-2004 08:54 PM
How to write script for telnet session
I want to write a script ( .sh ) for telnet session and auto login to the system. How to do it ? Please help
- Tags:
- telnet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 09:00 PM
06-29-2004 09:00 PM
Re: How to write script for telnet session
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 09:02 PM
06-29-2004 09:02 PM
Re: How to write script for telnet session
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072
sks
- Tags:
- broken URL link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 09:06 PM
06-29-2004 09:06 PM
Re: How to write script for telnet session
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 09:17 PM
06-29-2004 09:17 PM
Re: How to write script for telnet session
check this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072
Anyway this was posted more times in ITRC forum, try to insert keywords 'telnet script' in ITRC search.
Best regards,
Ettore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 09:26 PM
06-29-2004 09:26 PM
Re: How to write script for telnet session
Script:
Telnet ip-address
sleep 5
echo username
sleep 5
echo password
I try this, but it isn't work. Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 10:10 PM
06-29-2004 10:10 PM
Re: How to write script for telnet session
But, you'll find that Expect is really what you need, if rsh (or ssh) won't be satisfactory (why ??).
Ant (what make is for C, ant is for Java) has also telnet scripting capabilities).
Cheers
Nicolas
- Tags:
- expect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2004 01:47 AM
06-30-2004 01:47 AM
Re: How to write script for telnet session
use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10,
Prompt => '/bash\$ $/');
$t->open("sparky");
$t->login($username, $passwd);
@lines = $t->cmd("/usr/bin/who");
print @lines;
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2004 01:06 AM
07-01-2004 01:06 AM
Re: How to write script for telnet session
Download HERE:
http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.41/
#!/usr/bin/expect
spawn telnet
expect "login"
send "USERNAME\r"
expect "Password:"
send "PASSWORD\r"
expect "# "
YOU CAN SEND and Expect commands..
Get the OReilly Book "Expect"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2004 01:08 AM
07-01-2004 01:08 AM
Re: How to write script for telnet session
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2004 01:29 AM
07-01-2004 01:29 AM
Re: How to write script for telnet session
PERL has a telnet module. With it, I can login to my routers, enter commands to the routers to gather statistics. The script looks like this
#!/usr/contrib/bin/perl -w -I/opt/perl/lib/5.6.1/Net
#
use Telnet;
$|=1;
$Vanguard=shift(@ARGV);
$Password=shift(@ARGV);
$theVanguard=Net::Telnet->new(Timeout=>10,Prompt=>'/OK\n/',Host=>$Vanguard)
or die("Cannot Connect $Vanguard");
print "Hostname : $Vanguard\n";
#################
# Wait for OK - then send ATDS to connect
#################
$theVanguard->prompt("/Enter Password:/");
@listing=$theVanguard->cmd("atds");
print "@listing";
###
# Enter password and wait for enter selection prompt
###
$theVanguard->prompt('/Enter Selection:/');
@listing=$theVanguard->cmd($Password) or die ("Wrong Password $Vanguard\n");
print "@listing";
###
# Enter Commands to get statistics
###
$theVanguard->prompt('/Enter Selection:/');
@listing=$theVanguard->cmd("5");
print "@listing";
The $theVanguard=Net::Telnet->new(Timeout=>10,Prompt=>'/OK\n/',Host=>$Vanguard)
opens the connection to the host($Vanguard which is the first argument passed to the script) and waits for the host to respond with "OK" for up to 10 seconds. If it fails then the die clause is executed.
It sends the password to the host (which is the second argument passed to the script) and waits for up to 10 seconds for the host to respond with "Enter Selection"
When the enter selection is sent, it starts sending commands to the host. The @listing array contains the host's responses to the commands that are printed to stdout. I generally redirect standard out to a file for later review.
PERL Black Book ISBN: 1-57610-465-6 Publiched by CoriolisOpen Press Written by Steven Holzer is an excellent resource and contains the documentation on using the telnet module.
-Good Luck
- Tags:
- telnet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2004 02:13 AM
07-01-2004 02:13 AM
Re: How to write script for telnet session
We are using it for in house OLTP between multiple boxes, inserting records into Informix, Postgres or Mysql databases..
In addition to automated file transfers..
I general use perl for in file edits, using perl -pi -e g/