Operating System - HP-UX
1752379 Members
5905 Online
108788 Solutions
New Discussion юеВ

Re: Script writing to create files of important outputs

 
Jeffrey Shannon
Contributor

Script writing to create files of important outputs

I am writing my first script ever and I'm looking for a little help. I need to write a script that takes important host information and writes the output to a text file and then e-mails these files out of the server, in case the server were to go down. Some important outputs I'm looking at are:
ioscan...
bdf
vgdisplay
lanscan
swlist
.
.
.
I'm just looking for something to use as a basis to work off of....any help?
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: Script writing to create files of important outputs

Try something like this:

#!/sbin/sh

FILE=/tmp/outputfilename

echo "ioscan output" >> $FILE
ioscan >> $FILE
echo "" >> $FILE
echo "bdf output" >> $FILE
bdf >> $FILE
echo "" >> $FILE
echo "vgdisplay output" >> $FILE
vgdisplay -v >> $FILE
echo "" >> $FILE
echo "lanscan output" >> $FILE
lanscan >> $FILE
echo "" >> $FILE
echo "swlist output" >> $FILE
swlist -l product >> $FILE

mailx -s "Output from commands" yourname@somewhere.com < $FILE

Edward Alfert_2
Respected Contributor

Re: Script writing to create files of important outputs

bdf -i > /var/tmp/sysinfo.txt
anycommand >> /var/tmp/sysinfo.txt
anothercommand >> /var/tmp/sysinfo.txt
mailx -s 'Sys Info' you@domain.com < /var/tmp/sysinfo.txt

Put that in a script, make the script executable, then run the script
"Do what you love and you will never work a day in your life." - Confucius
Uday_S_Ankolekar
Honored Contributor

Re: Script writing to create files of important outputs

Hi,

The hp porting site has a script named sysinfo.sh This will do whatever information you required from the servers. this script also gives you output in html format.
Here is the adress:

http://hpux.cs.utah.edu/hppd/

Once the file created (/tmp) you can send that file as an attachment in mail or do a ftp.

Goodluck,
-USA..

Good Luck..
Craig Rants
Honored Contributor

Re: Script writing to create files of important outputs

Jeffery,
You will never know how you got along without scripting before! As far a script, follow Patrick's format and you can't go wrong. We can't know what is important to you however.
You know what you want to see, so find the command to give you that information and plug it into the script.

Happy Scripting,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Joseph C. Denman
Honored Contributor

Re: Script writing to create files of important outputs

Hi Jeffery,

Attached is a good collector script I got from another thread quit a while ago. Check it out, I think it does what you need.

...jcd...
If I had only read the instructions first??