- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- telnet to a remote server (router/switch) in a scr...
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
05-18-2007 07:54 AM
05-18-2007 07:54 AM
telnet to a remote server (router/switch) in a script
I need to execute 3 commands on the MPR periodically.
I tried using ssh but it keeps asking for the password of admin.
ssh admin@hostname
I tried telnet -inv telnet.sh, where telnet.sh contains
open hostname
user username password
The above telnet is similar to ftp -inv ftp.sh with the values inside ftp.sh file. That didn't work, keeps asking for the username and password.
I tried telnet -l, but that asks for username/password as well.
Is there anyway I could accomplish this - I don't know if we could use 'expect' kind of tools.
Please help.
Thanks!
Ravi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 08:01 AM
05-18-2007 08:01 AM
Re: telnet to a remote server (router/switch) in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 08:20 AM
05-18-2007 08:20 AM
Re: telnet to a remote server (router/switch) in a script
/usr/contrib/bin/perl telnet_in_script.pl
I'm getting the following error message:
Can't locate strict.pm in @INC (@INC contains: /opt/perl5/lib/5.00502/PA-RISC1.1
/opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib
/site_perl/5.005 .) at telnet_in_script.pl line 3.
BEGIN failed--compilation aborted at telnet_in_script.pl line 3.
Thanks!
Ravi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 08:35 AM
05-18-2007 08:35 AM
Re: telnet to a remote server (router/switch) in a script
http://hpux.its.tudelft.nl/hppd/hpux/Languages/perl-5.8.8/
Executing a Perl script is similar to executing a shell script.
If the first line of a Perl script looks something like:
#!/usr/bin/perl
Then all your have to do is "myperl.pl" otherwise "perl myperl.pl" assumming that perl is in your PATH.
In any event, Perl's Net::Telnet module makes this simple and is easier than expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 08:59 AM
05-18-2007 08:59 AM
Re: telnet to a remote server (router/switch) in a script
$ export PATH=/opt/perl/bin:$PATH
$ cd /opt/perl/bin
$ ./perl -version
This is perl, v5.8.3
cd /home/
$ which perl
/opt/perl/bin/perl
perl telnet_in_script.pl
results in the following error:
Can't locate Net/Telnet.pm in @INC (@INC contains: /opt/perl/lib/5.8.3/PA-RISC1.
1-thread-multi /opt/perl/lib/5.8.3 /opt/perl/lib/site_perl/5.8.3/PA-RISC1.1-thre
ad-multi /opt/perl/lib/site_perl/5.8.3 /opt/perl/lib/site_perl .) at telnet_in_s
cript.pl line 4.
BEGIN failed--compilation aborted at telnet_in_script.pl line 4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 09:13 AM
05-18-2007 09:13 AM
Re: telnet to a remote server (router/switch) in a script
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
Download the gzipped file and gunzip zip then untar it. There will then be a README file that will take you through the rest of the installation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 11:04 PM
05-18-2007 11:04 PM
Re: telnet to a remote server (router/switch) in a script
expect [http://expect.nist.gov/] is the correct method. Ot else you can do with netcat (nc).
Here is the telnet way. You have to use sleep in between your commands.
#!/usr/bin/ksh
(
sleep 4
echo open hostname
sleep 3
echo username
sleep 2
echo passwd
sleep 2
echo ls /tmp
sleep 2
sleep 1
echo who am i
sleep 1
echo exit
)|telnet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 09:37 PM
05-20-2007 09:37 PM
Re: telnet to a remote server (router/switch) in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 02:11 AM
05-21-2007 02:11 AM
Re: telnet to a remote server (router/switch) in a script
telnet using the sleep given by Rasheed gives the following message and doesn't execute anything (immediately exits):
Telnet TERMINAL-SPEED option ON
Connection closed by foreign host.
telnet> Trying...
Connected to 172.28.196.123.
Escape character is '^]'.
Local flow control on
perl suggestions given by Clay helped me install perl and use perl 5.8.8 without the Telnet.pm error, but the telnet.pl script just sits there without executing any commands after I provided the required arguments it needed.
ps: points have been submitted accordingly.
Thanks!
Ravi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 05:04 PM
05-21-2007 05:04 PM
Re: telnet to a remote server (router/switch) in a script
When you manually telnet to the said router how much time it takes. If it takes longer than usual, then increase the first sleep value to a higher value according to the connection speed. Try increasing to 8, 9, etc. It has to work.
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 05:16 PM
05-21-2007 05:16 PM