- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- favourite sysadmin scripts you always keep around....
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
09-17-2002 12:18 PM
09-17-2002 12:18 PM
Re: favourite sysadmin scripts you always keep around....
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2002 12:42 PM
09-17-2002 12:42 PM
Re: favourite sysadmin scripts you always keep around....
order to correctly print formatted output to
printers attached to PC's running MS Windows.
The 1st script is lp.1020 and is an lp wrapper
script. The documentation on how to use the
script is within the script itself. Basically
it "replaces" /usr/bin/lp (which is renamed to
lp.bin). It preformats the output using HP's
own print drivers and then sends that output
as raw output to the printer connected to the
PC.
The 2nd script is just an installation script
for lp.1020. (i had too many servers to
add this to by hand :-)
NOTE: this was not tested on 11.x. This will
work on 9.0x with modification of the
directories from /var to /usr.
I hope these scripts are helpful. :-)
Larry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 12:06 AM
09-18-2002 12:06 AM
Re: favourite sysadmin scripts you always keep around....
Since there were hundreds of files with wrong permissions I needed an automatic way to fix them. The swlist output is much easier to parse... why should I use the swverify results?
After running the script you may use swverify to verify the results...
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2002 12:50 PM
10-01-2002 12:50 PM
Re: favourite sysadmin scripts you always keep around....
Make sure to configure the PRINTER AND PCLTRANS_HOST in the quickshot script.
I also have a button created for CDE as well as desktop definitions so users simply click a button and out comes a pretty picture. Handles remote printing so that the script workes on non HP-UX systems. Note you must configure either ~/.rhosts or /etc/hosts.equiv for remsh with 0 auth.
Since I can only attach 1 file, the buttons and CDE definitions will cost ya! hehe
Have fun!
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2002 12:58 PM
10-01-2002 12:58 PM
Re: favourite sysadmin scripts you always keep around....
Forgot to mention that my accounting section requires NIS (lazy and not recoding that part). If you need accounting and are not running NIS then feel free to hack away.
If you dont need accounting then keep it set to 0!
Have more fun!
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:03 AM
10-03-2002 06:03 AM
Re: favourite sysadmin scripts you always keep around....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:05 AM
10-03-2002 06:05 AM
Re: favourite sysadmin scripts you always keep around....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:11 AM
10-03-2002 06:11 AM
Re: favourite sysadmin scripts you always keep around....
#! /usr/bin/ksh
#this script will work but is not as accurate as /var/adm/scripts/NIS_activity_log.sh
#or /var/adm/scripts/activity_log.sh (for non-NIS machines)
#this file will examine when the last activity of a user is
#written by John Meissner on 4/23/2002
BOLD="`tput smso`"
NORMAL="`tput rmso`"
if [ `id|cut -c5-11` != "0(root)" ]
then
echo "Quitting - You must run this script as Root"
exit 1
fi
################################# setting up variables ############################
month=$(date | awk '{print $2}')
Jan=1
Feb=2
Mar=3
Apr=4
May=5
Jun=6
Jul=7
Aug=8
Sep=9
Oct=10
Nov=11
Dec=12
############################## running script ####################################
if [ $month = Jan ]
then mdate=$Jan
elif [ $month = Feb ]
then mdate=$Feb
elif [ $month = Mar ]
then mdate=$Mar
elif [ $month = Apr ]
then mdate=$Apr
elif [ $month = May ]
then mdate=$May
elif [ $month = Jun ]
then mdate=$Jun
elif [ $month = Jul ]
then mdate=$Jul
elif [ $month = Aug ]
then mdate=$Aug
elif [ $month = Sep ]
then mdate=$Sep
elif [ $month = Oct ]
then mdate=$Oct
elif [ $month = Nov ]
then mdate=$Nov
elif [ $month = Dec ]
then mdate=$Dec
fi
((mdate2=$mdate-1))
if [ $mdate2 = 1 ]
then month2=Jan
elif [ $mdate2 = 2 ]
then month2=Feb
elif [ $mdate2 = 3 ]
then month2=Mar
elif [ $mdate2 = 4 ]
then month2=Apr
elif [ $mdate2 = 5 ]
then month2=May
elif [ $mdate2 = 6 ]
then month2=Jun
elif [ $mdate2 = 7 ]
then month2=Jul
elif [ $mdate2 = 8 ]
then month2=Aug
elif [ $mdate2 = 9 ]
then month2=Sep
elif [ $mdate2 = 10 ]
then month2=Oct
elif [ $mdate2 = 11 ]
then month2=Nov
elif [ $mdate2 = 0 ]
then month2=Dec
fi
find /home -name .sh_history | awk '{print "ll " $1}' > /tmp/hist
chmod +x /tmp/hist
echo "${BOLD} Most recent user login activity shown ${NORMAL}"
echo "${BOLD} User Month Date Time ${NORMAL}"
/tmp/hist | awk '{print $3 " " $6 " " $7 " " $8}' | grep -v $month | grep -v $month2 >> /tmp/hist.log
more /tmp/hist.log
rm /tmp/hist
rm /tmp/hist.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:14 AM
10-03-2002 06:14 AM
Re: favourite sysadmin scripts you always keep around....
#! /usr/bin/ksh
#this script is intended to run only on NIS enabled machines
#this file will examine when the last activity of a user is
#written by John Meissner on 4/23/2002
BOLD="`tput smso`"
NORMAL="`tput rmso`"
if [ `id|cut -c5-11` != "0(root)" ]
then
echo "Quitting - You must run this script as Root"
exit 1
fi
################################# setting up variables ############################
month=$(date | awk '{print $2}')
Jan=1
Feb=2
Mar=3
Apr=4
May=5
Jun=6
Jul=7
Aug=8
Sep=9
Oct=10
Nov=11
Dec=12
############################## running script ####################################
if [ $month = Jan ]
then mdate=$Jan
elif [ $month = Feb ]
then mdate=$Feb
elif [ $month = Mar ]
then mdate=$Mar
elif [ $month = Apr ]
then mdate=$Apr
elif [ $month = May ]
then mdate=$May
elif [ $month = Jun ]
then mdate=$Jun
elif [ $month = Jul ]
then mdate=$Jul
elif [ $month = Aug ]
then mdate=$Aug
elif [ $month = Sep ]
then mdate=$Sep
elif [ $month = Oct ]
then mdate=$Oct
elif [ $month = Nov ]
then mdate=$Nov
elif [ $month = Dec ]
then mdate=$Dec
fi
((mdate2=$mdate-1))
if [ $mdate2 = 1 ]
then month2=Jan
elif [ $mdate2 = 2 ]
then month2=Feb
elif [ $mdate2 = 3 ]
then month2=Mar
elif [ $mdate2 = 4 ]
then month2=Apr
elif [ $mdate2 = 5 ]
then month2=May
elif [ $mdate2 = 6 ]
then month2=Jun
elif [ $mdate2 = 7 ]
then month2=Jul
elif [ $mdate2 = 8 ]
then month2=Aug
elif [ $mdate2 = 9 ]
then month2=Sep
elif [ $mdate2 = 10 ]
then month2=Oct
elif [ $mdate2 = 11 ]
then month2=Nov
elif [ $mdate2 = 0 ]
then month2=Dec
fi
print $month $month2 > /tmp/mlist
more /etc/passwd.nis | sed 's/:/ /g' > /tmp/hist
more /tmp/hist | awk '{print $1}' > /tmp/hist2
number=$(wc -l /tmp/hist2 | awk '{print $1}')
((number2=$number+1))
count=0
while [ "$count" != "$number2" ]
do
sed -n '1p' /tmp/hist2 > /tmp/finger_user.list
tuser=$(cat /tmp/finger_user.list)
finger $tuser | egrep -i 'Last|Never' > /tmp/finger_user.list2
paste /tmp/finger_user.list /tmp/finger_user.list2 >> /tmp/user.info
more /tmp/hist2 | sed -n '2,$p' > /tmp/hist2a
mv /tmp/hist2a /tmp/hist2
let "count += 1"
done
echo " Users who have not logged in within the past 60 days on $hostname "
more /tmp/mlist | awk '{print "more /tmp/user.info | egrep -i \"Last|Never\" | grep -v " $1 " | grep -v " $2 }' > /tmp/inactive
chmod +x /tmp/inactive
#you can output the results of this script to a file by redirecting the command below as such:
#/tmp/inactive > filename
/tmp/inactive
rm /tmp/hist
rm /tmp/hist2
rm /tmp/mlist
rm /tmp/finger_user.list
rm /tmp/finger_user.list2
rm /tmp/user.info
rm /tmp/inactive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:18 AM
10-03-2002 06:18 AM
Re: favourite sysadmin scripts you always keep around....
#! /usr/bin/ksh
pntr=$1
echo $pntr
sed 's/orientation\=\"def\"/orientation\=\"l\"/' /etc/lp/interface/model.orig/$pntr > /etc/lp/interface/model.orig/tmp.lp
mv /etc/lp/interface/model.orig/tmp.lp /etc/lp/interface/model.orig/$pntr
sed 's/pitch\=\"def\"/pitch\=\"13\.7\"/' /etc/lp/interface/model.orig/$pntr > /etc/lp/interface/model.orig/tmp.lp
mv /etc/lp/interface/model.orig/tmp.lp /etc/lp/interface/model.orig/$pntr
sed 's/textlen\=\"def\"/textlen\=\"66\"/' /etc/lp/interface/model.orig/$pntr > /etc/lp/interface/model.orig/tmp.lp
mv /etc/lp/interface/model.orig/tmp.lp /etc/lp/interface/model.orig/$pntr
sed 's/vsi\=\"def\"/vsi\=\"5\.4\"/' /etc/lp/interface/model.orig/$pntr > /etc/lp/interface/model.orig/tmp.lp
mv /etc/lp/interface/model.orig/tmp.lp /etc/lp/interface/model.orig/$pntr
echo " $1 is now setup for landscape printing"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:28 AM
10-03-2002 06:28 AM
Re: favourite sysadmin scripts you always keep around....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 06:41 AM
10-03-2002 06:41 AM
Re: favourite sysadmin scripts you always keep around....
Requires: "expect"
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Thu May 9 13:48:07 2002
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don
set timeout -1
spawn telnet mou065
match_max 100000
expect -exact "
\r
login: "
send -- "username\r"
expect -exact "username\r
Password: "
send -- "password\r"
send -- "clear\r"
expect -exact "clear\r"
interact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2002 07:27 AM
10-07-2002 07:27 AM
Re: favourite sysadmin scripts you always keep around....
#written by John Meissner
#This script will read the /etc/passwd or the /etc/passwd.nis file depending; and create the home directories and grant the propper permissions to
#the /home/$logname directories.
echo " Is an NIS server (y/n) "
until [ "$answer" = "y" ] || [ "$answer" = "Y" ] ||
[ "$answer" = "n" ] || [ "$answer" = "N" ] ; do
echo " Answer with (y/n) !\c"
read answer
done
case $answer in
y|Y)
var1=$(cat /etc/passwd.nis | grep -v root | grep -v lp | grep -v bin | grep -v sys | grep -v daemon | grep -v adm | awk -F: '{print $1}')
for i in $var1
do
mkdir -p /home/$i
unset $var1
done
;;
n|N)
var1=$(cat /etc/passwd | grep -v root | grep -v lp | grep -v bin | grep -v sys | grep -v daemon | grep -v adm | awk -F: '{print $1}')
for i in $var1
do
mkdir -p /home/$i
unset $var1
done
esac
#this lines will chown and chgrp the users directory so that
#the user will own their home directory and the group "users" will be the group ID
#this must be copied and run from the /home directory on the desired server
cd /home
ll /home | awk '{print $9}' | grep -v lost+found | grep -v opc_op | grep -v root | grep -v sys | grep -v daemon | grep -v adm | grep -v sys | grep -v lp > ulist
cat /home/ulist | awk '{print "chown " $1 ":users "$1}' > glist
chmod +x glist
./glist
rm ulist glist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2002 07:35 AM
10-07-2002 07:35 AM
Re: favourite sysadmin scripts you always keep around....
#! /usr/bin/ksh
cd /opt/mx/bin
var1=$(who -mT | sed -e 's/.*[ ]\([^ ]*\)$/\1/')
export DISPLAY=$var1:0.0
/opt/mx/bin/scmgr &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2002 10:08 AM
10-07-2002 10:08 AM
Re: favourite sysadmin scripts you always keep around....
Usage: logstats username
#! /bin/sh
# loginstat: login accounting by usr/month
# @(#): loginstat.SH,v 0.1 1997/30/10 12:30:05 MET Exp $
# By Luke Th. Bullock
#
if [ $# -eq 0 ] ; then
echo "usage: loginstat user|Month (-help for help)" 1>&2
exit 1
fi
if [ $1 = -help ]; then
cat <
user - prints yearly stat
-help - prints this info
^C (CTRL+C) - Break|Stop Script
EOF
elif [ $2 ]; then
echo "`last $1|grep $2|wc -l` logins for $1 in $2"
else
echo "Login stats for $1 based on wtmp entries:"
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
do
echo "`last $1|grep $i|wc -l` logins in $i"
done
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2002 07:14 AM
10-08-2002 07:14 AM
Re: favourite sysadmin scripts you always keep around....
#! /usr/bin/ksh
#written by John Meissner
#this script will examine the /home directory for directories owned by a UID (orphaned because
#the user changed their UID and didn't change ownership of their files
#and reclaim all their files
touch files.list new_owner.sh owner.sh
rm new_owner.sh owner.sh files.list
touch new_owner.sh owner.sh files.list
ll /home/ | awk '{print $3,$9}' | grep [0-9] > home.list
cat home.list |
while read file
do
var1=$(cat home.list | sed -n '1p' | awk '{print $1}')
var2=$(cat home.list | sed -n '1p' | awk '{print $2}')
if [ "$var1" = "$var2" ]
then
sed -n 1d home.list > home.list2
mv home.list2 home.list
unset var1 var2
elif [ "$var1" != "$var2" ]
then
cat home.list | print "find / -user $var1 | awk '{print \"chown $var2 \" \$1}' >> new_owner.sh" >> owner.sh
unset var1 var2
sed -n 1d home.list > home.list2
mv home.list2 home.list
fi
done
chmod +x owner.sh
./owner.sh
chmod +x new_owner.sh
cat new_owner.sh
./new_owner.sh
rm owner.sh new_owner.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2002 10:15 AM
10-08-2002 10:15 AM
Re: favourite sysadmin scripts you always keep around....
Please remove his entry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2002 06:46 AM
10-09-2002 06:46 AM
Re: favourite sysadmin scripts you always keep around....
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2002 06:58 AM
10-09-2002 06:58 AM
Re: favourite sysadmin scripts you always keep around....
which is the final tested product. This script when run will allow you to select a particular printer queue from a menu or all printers on the system and perform a status check on that printer.
Hope you enjoy it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2002 03:26 AM
10-10-2002 03:26 AM
Re: favourite sysadmin scripts you always keep around....
Here is perl script which gives the Total Allocated and Free size(in MB) of all the Volume Groups in a system
-Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:50 AM
10-14-2002 07:50 AM
Re: favourite sysadmin scripts you always keep around....
This sets the title/icon of hpterm, dtterm and xterm. Likes to be added to /etc/profile.
# Set Window and Icon name
winIcon="$(hostname)"
winTitle="$winIcon $(uname -r) $(model)"
case "$TERM" in
dtterm|xterm)
echo "\033]1;$winIcon\007\c"
echo "\033]2;$winTitle\007\c"
;;
hp*|*2392*)
echo "\033&f-1k${#winIcon}D${winIcon}\c"
echo "\033&f0k${#winTitle}D${winTitle}\c"
;;
esac
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 08:10 AM
10-14-2002 08:10 AM
Re: favourite sysadmin scripts you always keep around....
#!/usr/bin/ksh
# The script is cleaning all printer requests older than 3 days
# Script logs in /tmp/clear_spool.log
# TBA - 14/10/2002
my_month=`date | awk '{print $2}'`
echo "Month is: " $my_month
my_day=`date | awk '{print $3}'`
((my_day = $my_day -1))
#echo $my_day
echo "Delete jobs older than: " $my_day
old_request_list=`lpstat -i -o | grep ^lp | awk -v m=$my_month -v d=$my_day '{ if ( ($5 != m ) OR ( $6 < d) ) print $1 }'`
for i in $old_request_list
do
cancel $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2002 01:29 AM
10-16-2002 01:29 AM
Re: favourite sysadmin scripts you always keep around....
********** NOTICE **********
this is the official end of this branch of the subject!
The thread continues
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html
so post your contribiutions there from now on..
ZERO points to this thread from now on - even for efficient prime number generator scripts..
Thanks,
Bill
******** IMPORTANT *********
********** NOTICE **********
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2002 04:53 AM
10-16-2002 04:53 AM
Re: favourite sysadmin scripts you always keep around....
MC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2002 05:10 AM
10-16-2002 05:10 AM
Re: favourite sysadmin scripts you always keep around....
********** NOTICE **********
this is the official end of this branch of the subject!
please post your contributions to:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html
and you'll get your points there!
Thanks,
Bill
******** IMPORTANT *********
********** NOTICE **********