- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to log in to different servers via a scrip...
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
10-23-2002 05:08 AM
10-23-2002 05:08 AM
how to log in to different servers via a script?
I'm currently writing a script that should log into different servers and execute some unix commands. I know how to do this (logging in I mean)with ftp, but since I need to execute unix commands, this is of no use.
So, the general structure of my script should be something like this:
1) give username & passwords (this has to be only once, since we have one general password for all servers)
2) login to first server from a file or something (for $servername in $serverlist do ...)
3) execute some (a lot) unix commands
4) log in to next server from the serverlist
5) execute commands
etc etc ...
Can somebody please help me since this would make my daily routine much more easier :-)
Cheers
Wim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 05:17 AM
10-23-2002 05:17 AM
Re: how to log in to different servers via a script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 05:19 AM
10-23-2002 05:19 AM
Re: how to log in to different servers via a script?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 05:23 AM
10-23-2002 05:23 AM
Re: how to log in to different servers via a script?
You could use remsh or ssh to run the commands on the remote server. The basic process could be:
create a script of the commands you want to run on the remote systems
rcp the script to the remote systems
remsh (execute) the script on the remote systems
You can do the same procedure using ssh.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 05:29 AM
10-23-2002 05:29 AM
Re: how to log in to different servers via a script?
rrun 'bdf |grep "[890][0-9]% "'
or
rrun 'uptime'
#!/usr/bin/ksh
USAGE="usage:rrun 'command' < i.e, uname -a or who -r >"
# Get command to run from command line
COMMAND=$*
# Check to see if it is blank
if [[ $COMMAND = "" ]]
then
print $USAGE
exit 1
fi
# Check for rm, mv, shutdown and other nasty commands and shut it down
# Enter your list of restricted commands below
if [[ "$COMMAND" = +(*rm*||*mv*||*reboot*||*shutdown*||*init*) ]]
then
echo
echo "******************************************"
echo
echo "Your command: $COMMAND"
echo "Will not allow rm, mv, init, reboot or shutdown!"
echo
echo "******************************************"
exit 1
fi
# If the command is not blank and not nasty then do it
for i in `cat /usr/local/etc/rrun.conf` #Name of file containing system names
do
print "************************ $i ***************************"
# print "Running the following command on $i:$COMMAND"
print $COMMAND
remsh $i -n $COMMAND
# print "***********************************************************"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 05:34 AM
10-23-2002 05:34 AM
Re: how to log in to different servers via a script?
Expect is your friend. Expect helps you automate interactive shell sessions.
I have been using a expect script to login to a server. The passwords i have are autogenerated by a script and are shared among users. So, i have a script which reads the passwords from a file and logs in to the server and spawns a shell for me.
If u need, u instead of spawning a shell, u could give the set of commands and using another script call this one for n no of times, one for each host.
A snippet of the script is attached.
HTH
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 10:17 PM
10-23-2002 10:17 PM
Re: how to log in to different servers via a script?
1. r-commands are simple but they are always security issue. Please think about your security requirements.
2. EXPECT really works, but if you know PERL, just use special modules for telnet, ftp, ssh and whatever you want. (http://www.cpan.org)
I think that it's enaugh to know shell and PERL langauages to do any administrative tasks.
3. Some alternative solutions for your task (sure with their own drawbacks)
- running scripts locally and retrieving results by ftp
- running scripts locally and placing results on NFS share
- storing scripts on NFS share, running scripts from NFS share (with possible parameters), storing results on NFS share.
Just my 2 cents.
BR,
Mihail

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2002 02:20 AM
10-24-2002 02:20 AM
Re: how to log in to different servers via a script?
you may want to have a look at Service Control Mgr (free download) in case you have to look after [ $N -ge 10 ] boxes.
"Service Control Manager makes
managing a large number of systems much easier. A nice feature of SCM is
being able to do everything from either the command line, a GUI interface,
or a browser window. Service Control Manager is similar to SUDO, but it can
be leverage across many systems. Any user can be given access to selected
root-privileged commands without being given the root password. " (itrc training ad)
The so called tools are pretty cool- you can eg push the creation of a local user with a defined password (kind of nis without the nw load;)
to get started see
http://www.software.hp.com/products/SCMGR/index.html
http://www.software.hp.com/products/SCMGR/downloads.html
ServiceControl Manager is a software product that allows you to manage
groups of HP-UX systems from a central server. It includes integrated
products that provide centralized management for installation,
configuration, inventory and other administrative tasks. $0.0 Free
Download
http://www.software.hp.com/products/SCMGR/info.html
Release Notes 2.5 (v. A.02.05)
README [ 1020.txt ] [ 1100.txt ] [ 11i.txt ]
Technical Reference 2.5 (v. A.02.05)
Installation Guide 2.5 (v. A.02.05)
Browsable Help System
--whitepaper on
http://www.hp.com/products1/unix/management/infolibrary/index.html#configuration :
http://www.hp.com/products1/unix/management/infolibrary/scmwp.pdf (33pages)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2002 02:36 AM
10-24-2002 02:36 AM
Re: how to log in to different servers via a script?
----------------------------------
#!/usr/bin/sh
command=`ll`
sysadm=/usr/local/bin
for server in server1 server2 server3
do
remsh $server "$command $sysadm"
done
---------------------------------
should execute ll /usr/local/bin : on server 1,2,3.
Hope this helps.