- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Telnet through 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
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
08-07-2006 07:15 PM
08-07-2006 07:15 PM
I want to write a unix script to login to a remote host and to collect logs.
But once telnet session is started then my script is not running.. once the telnet is closed my script runs.
please help to write a script so that I would be able to fire a telnet command through script.
Thanks and Regards
Jayachandran,G
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 08:29 PM
08-07-2006 08:29 PM
Re: Telnet through script
or use Perl Net::Telnet,
or even the Perl Expect if you don't like tcl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 09:16 PM
08-07-2006 09:16 PM
Re: Telnet through script
as an alternative to setting up a telnet session via expect, have you thought about remsh or just collecting the logs via ftp.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 09:42 PM
08-07-2006 09:42 PM
Re: Telnet through script
To add some more details..
I'm trying from solaris server.....
Peter
both cmd execution and ftp log file collection must be done in order to reach my goal.
Once I have used normal telnet commands script with some sleep option.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 11:32 PM
08-07-2006 11:32 PM
Re: Telnet through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2006 12:49 AM
08-08-2006 12:49 AM
Re: Telnet through script
But as you have to execute a command before I think you will need the expect script so probably it would be better to use it for the full task.
Anyway, be concious that the expect script must contain username and password, so be concious about the security issues it would mean.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2006 01:32 AM
08-08-2006 01:32 AM
SolutionYou can easily combine remote command execution and secure copying of files just using ssh
(there's absolutely no need for scp if you need to copy files).
In fact this is how I transfer (in a trusted network) public keys for passwordless logins.
First you need to create a pair of either DSA or RSA keys (probably both won't hurt).
If you have never before initiated an ssh session on your solaris box before then most likely $HOME/.ssh subdir is missing.
You can create it manually but because of the pickiness of ssh with file ownerships and permissions (if strictmodes is enabled, as should be the case) it's better to have ssh it done for you.
Therefore you only need to connect to another ssh host (no login there required), and accept its hostkey (in a hostile environment you should double check the issued fingerprint of the remote host key)
e.g.
$ ssh someuser@somesshhost
If you accepted the hostkey you will find a .ssh dir in your $HOME together with a known_hosts file, all with correct mode bits.
Next generate a pair of keys.
$ ssh-keygen -t rsa -b 1024 -N "" -f ~/.ssh/id_rsa
should generate a passphraseless RSA key pair.
Now on the other Solaris box where you remotely want to execute commands or copy files you need to place the public key of the just generated pair in some user's $HOME/.ssh/authorized_keys file that you have access to.
Let's assume you have root access there (but this isn't necesarry) just to show how to copy files without requiring scp.
$ ssh root@otherbox 'cat >>~otheruser/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub
Similarily, you can recursively copy whole directory trees by just executing ssh commands remotely (in the very simple example above the cat command).
You can also combine several commands by separating them with quoted simicolons.
You only have to be careful to quote any meta character that should be executed on the remote box to prevent your local shell from interpreting it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2006 11:37 PM
08-08-2006 11:37 PM
Re: Telnet through script
Thankx a lot now I'm using ssh and trying to execute the commands and it really works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2006 11:38 PM
08-08-2006 11:38 PM