- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help
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
03-17-2005 12:42 AM
03-17-2005 12:42 AM
I would like to create a script that i can run from one HPUX server that will run "dmesg", output this and then telnet to another server and run "dmesg" etc... then put it to a file that i can print or look at.. by doing this, i will be able to run once and review nightly.
my question is, how do i, in a script log into another server, run the command, then log into another etc.... is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 12:48 AM
03-17-2005 12:48 AM
SolutionNow, after this , you can run a command like ...
for i in servera serverb serverc serverd
do
echo -------------------
echo Server $i
echo -------------------
ssh $i "/usr/sbin/dmesg"
echo --------------------
done >> dmesg_log_file
This will contact each server run dmesg on each and put the results in "dmesg_log_file".
Quite simple really - once you've got ssh working and configured.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 12:48 AM
03-17-2005 12:48 AM
Re: script help
see man remsh
Run a remote shell and command
see also
www.shelldorado.com for learning
ex
hostname;remsh topaz -n pwd
xserv3
/usershome/steves
Local hostname then login dir on other machine topaz
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 12:50 AM
03-17-2005 12:50 AM
Re: script help
alternative to Chris's ssh is using remsh (which will need files seting up on each server) or expect (downloadable, but you can then mimic telnet sessions).
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 03:24 AM
03-17-2005 03:24 AM
Re: script help
what do you mean? echo what in this space..?
sorry, i am really bad at scripting. it's quite new to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 04:50 AM
03-17-2005 04:50 AM
Re: script help
echo just that, 'print what I am putting here.'
This print can be on screen or to a file or to error.
I would suggest you go with ssh instead of remsh. Once you have it setup on systems you can avoid ever using the remsh/telnet/ftp commands again - these are all substituted in ssh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 05:00 AM
03-17-2005 05:00 AM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 05:10 AM
03-17-2005 05:10 AM
Re: script help
What data do you want to gather?
dmesg is overwritten with time...so eventually - the data that you are looking for will be gone - until you reboot...
Better to get dat via an utility - like /opt/ignite/bin/print_manifest
or cfg2html or sysinfo301
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 05:49 AM
03-17-2005 05:49 AM
Re: script help
the buffer is full, it overwrites the earliest log. So a
better solution would be start a cron job that will run
once in every (say) 60 minutes and append it in a
file. The cron job should email this file once every
day.
Make sure that the cron job runs
# dmesg -
(dmesg with a dash as an argument). This will print
out only incremental dmesg logs.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 07:28 AM
03-17-2005 07:28 AM
Re: script help
Then use the syslogd utility, which is already running to log the messages that you want to that common log area.
All you will need to do is add a line to your /etc/syslog.conf file to log these messages to the log file
Sample line from syslog.conf
*.crit /nfsmountpoint/logs/syslog.glogal.crit
*.info;*.alert /nfsmountpoint/logs/syslog.general
restart syslogd by
/sbin/init.d/syslogd stop
/sbin/init.d/syslogd start
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 08:15 AM
03-17-2005 08:15 AM
Re: script help
it stops when asking for a password. I could put this in the file (i think) but can i just give root the ability to log in without asking for a password to run dmesg?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 08:43 AM
03-17-2005 08:43 AM
Re: script help
Now go to the user's home directory on each machine and make a key...
ssh-keygen -t rsa
or
ssh-keygen -t dsa
Be agreeable and answer all the prompts with defaults - and when asked - don't put in a password.
cd .ssh
now, You'll see a file there id_rsa.pub or id_dsa.pub.
cat id_rsa.pub >> authorized_keys
or
cat id_dsa.pub >> authorized_keys
Do the same on both servers
Now on machine a, copy the id_rsa (or dsa) file from machine b into a file called machineb (it just a temporary file name - call it what u want).
then, cat machineb >> authorized_keys
chmod -R og-rwx ~/.ssh
(secure up all those new files)
do the same on machine b, appending the public key file (id_rsa.pub or id_dsa.pub) to the authorized_keys file.
Now, just ssh from one machine to the other.
ssh machineb
It will ask you to add a key re: your host name, be agreeable and let it.
Do the same from the other machine.
Now, you're done - you can ssh back and forth.
Make sure to read your man pages on ssh and review security settings, etc. for the ssh services... once you're done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 07:49 PM
03-17-2005 07:49 PM
Re: script help
when you create the keys let the passphrase empty, otherwise at login you'll be asked again the passphrase - you cannot run ssh from the script with non-empty passphrases. Otherwise you can add the passphrases to the ssh-agent but it will not work as cronjob (I've tried my own)
have a lot of fun...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2005 12:32 AM
03-18-2005 12:32 AM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2005 12:34 AM
03-18-2005 12:34 AM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2005 12:57 AM
03-18-2005 12:57 AM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2005 01:28 AM
03-18-2005 01:28 AM