- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to telnet remote machines
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-19-2003 08:47 PM
06-19-2003 08:47 PM
I need to write a script which does a telnet to the remotes systems specified and run some commands there. With in the script I must be able to supply the user name and password,
I tried something like this but it didnt work,
for i in "sys1 sys2 sys3"
do
telnet $i <
password
`run some commands`
exit
EOF
done
Is there any way out?. I can't make use of rsh as the remote system does not support it.
Pl. help,
Thanks
Karthik S S
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 08:54 PM
06-19-2003 08:54 PM
Re: script to telnet remote machines
You won't be able to do the telnet like this as the password can never be passed in this fashion in HP-UX.
A product called "expect" will let do that kind of thing but I don't know the product myself.
My personal suggestions are either to create a trust between the 2 systems so you can use "remsh" (not the most secure option) or install SSH on your systems and use "ssh" to run the commands (much more secure).
Ollie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 08:57 PM
06-19-2003 08:57 PM
Re: script to telnet remote machines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 09:04 PM
06-19-2003 09:04 PM
SolutionThere are two major issues with your approach. Logging in directly as root and storing it's password in a text file. I suggest you use ssh for automated jobs.
If you are willing to take the risk, you can use 'expect' to achieve what you want. But you would need to understand it a bit before you can start on it.
Look at the following thread. I gave a simple example (in real world, you would be keeping a lot of error checking) on how expect can make interactive sessions non-interactive. There are examples available with expect that can help you understand it better.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x54e2c6af36b7d5118ff10090279cd0f9,00.html
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 09:54 PM
06-19-2003 09:54 PM
Re: script to telnet remote machines
Ollie/michael:
I need this because I need to take battery status every week from some 20 odd Sun T3 arrays which does not support any "r" commands. And I wanted to automate this using cron.
Thanks
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 10:03 PM
06-19-2003 10:03 PM
Re: script to telnet remote machines
But how do I pass multiple hosts to expect for doing some common tasks?? If I call the expect script from within a shell script it doesnt take the environmental variables...
Thanks
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2003 10:32 PM
06-19-2003 10:32 PM
Re: script to telnet remote machines
Why not run the same script on each server and just e-mail/ftp the results. Having the same script running from cron contains all the ENV variables we require and it is totally secure. That's why I asked why don't you ftp the results and then collate them on one system and post the results to yourself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 02:20 AM
06-20-2003 02:20 AM
Re: script to telnet remote machines
Take a look here :
http://steve-parker.org/sh/expct.shtml
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 06:17 AM
06-20-2003 06:17 AM
Re: script to telnet remote machines
Install secure shell and use scp and ssh. These are secure, they're easily scripted, and they're free. The only drawback is that they're a little slow on the initial connection while they swap public/private keys. But otherwise they're a dream to use, and they fundamentally solve your problem. Here's a quick-and-dirty example.
for HOST in HOST1 HOST2 HOST3 HOST4
do
ssh $HOST "Run command">>/tmp/txtfile
done
cat /tmp/txtfile|mailx -s "textfile" me@somewhere.com
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 07:04 PM
06-20-2003 07:04 PM
Re: script to telnet remote machines
As I have already told you I am using expect for collecting the battery status on Sun StorEdge T3 work group arrays which only supports telnet and ftp. Hence I cant use ssh on it ....
Thanks
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 08:16 PM
06-20-2003 08:16 PM
Re: script to telnet remote machines
SRVR="sys1 sys2 sys3"
for i in $SRVR
do
/bin/ftp -n $i | tee /tmp/$i-ftp.log <
ascii
cd /path
get file_1
get file_2
..more ftp commands..etc..
quit
EOF
done
This may work for you. I wouldn't do this for root as you woudn't want roots passw being sent in clear text. I'd suggest creating a user account that you could lock down for this purpose.
My scripting skills are mediocre at best, so make your changes and test to suit your needs.
Hope this helps,
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2003 08:47 AM
06-21-2003 08:47 AM