- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Parameter help inside script.
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
Discussions
Discussions
Forums
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
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-30-2002 06:45 AM
тАО09-30-2002 06:45 AM
I am trying to figure out the error i am getting from the script below, i understand its a parameter not set but I thought that as part of the script executes it will set that parameter during execution. Basically with this script I am trying to allow someone to query all printers on system or select a particular printer for the check.
can anyone shed some light on this.
Error: ./jdpstatus[80]: select_on: parameter not set
#! /usr/bin/ksh
# This script is utilized to gather printer information on all print queue's installed
# on a system using the hpnpadmin command.
# Environmental section
set -u
BASEDIR=/home/fgrosb01
DATE=`date +%m/%d/%Y`
YDATE=`TZ=CST+24 date +%m/%d/%Y`
SCRIPT_EXECUTION_TIME=$(date +'%H:%M:%S')
SCRIPT_REVISION="HPUX-b.11.00.01"
SCRIPT_HPUX_VERSION=$(uname -r)
SCRIPT_SYSTEM=$(uname - n)
SCRIPT_USER=$(whoami)
SCRIPT_EXECUTION_TIME=$(date +'%Y/%m/%d/%H:%M:%S')
echo $SCRIPT_SYSTEM \(Version $SCRIPT_REVISION\) $SCRIPT_EXECUTION_TIME
echo _____________________________________________________________________
echo
if [ ${SCRIPT_USER} != "root" ] ; then
echo
echo "This program must be executed utilizing the root logon id only"
echo
return 501
fi
echo _______________________________________________________________________
# Gather information about printer queue's on system.
##################################################################################
# Defaults
PS3="Please select desired printer: "
fulllist="`cd /etc/lp/interface;ls`"
all_printers ()
{
hpnpadmin ${fulllist}
}
select_printer ()
{
select prtname in ALL Quit ${fulllist}
do
[ "${prtname}" = "Quit" ] && exit 0
if test -n "${prtname}"
then
if test "${prtname}" = "ALL"
then
prtlist="${fulllist}"
else
prtlist="${prtname}"
fi
break
fi
done
hpnpadmin ${prtlist}
}
# Main
if test ${#} -ne 0
then
while getopts :s option
do
case ${option} in
s) select_on="Y";;
?) echo "Usage: ${0} [<-s>]"
exit 4 ;;
esac
done
fi
[ "${select_on}" = 'N' ] && all_printers || single_printer
exit 0
mvitux01@/home/fgrosb01#
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 06:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 06:58 AM
тАО09-30-2002 06:58 AM
Re: Parameter help inside script.
You've got "set -u" which means treat unset variables as an error when substituting, and in your test at around line 80, select_on hasn't necessarily been set, hence the error. Just initialise it first.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 07:15 AM
тАО09-30-2002 07:15 AM
Re: Parameter help inside script.
as per your suggestion robin, i moved the statement containing the select_on variable up in the script, now the script just passes thru with no input asked for or output given.
any clues?
mvitux01@/home/fgrosb01# ./jdpstatus
#! /usr/bin/ksh -v
# This script is utilized to gather printer information on all print queue's installed
# on a system using the hpnpadmin command.
# Environmental section
BASEDIR=/home/fgrosb01
DATE=`date +%m/%d/%Y`
YDATE=`TZ=CST+24 date +%m/%d/%Y`
SCRIPT_EXECUTION_TIME=$(date +'%H:%M:%S')
SCRIPT_REVISION="HPUX-b.11.00.01"
SCRIPT_HPUX_VERSION=$(uname -r)
SCRIPT_SYSTEM=$(uname - n)
SCRIPT_USER=$(whoami)
SCRIPT_EXECUTION_TIME=$(date +'%Y/%m/%d/%H:%M:%S')
echo $SCRIPT_SYSTEM \(Version $SCRIPT_REVISION\) $SCRIPT_EXECUTION_TIME
HP-UX (Version HPUX-b.11.00.01) 2002/09/30/11:17:12
echo _____________________________________________________________________
_____________________________________________________________________
echo
if [ ${SCRIPT_USER} != "root" ] ; then
echo
echo "This program must be executed utilizing the root logon id only"
echo
return 501
fi
echo _______________________________________________________________________
_______________________________________________________________________
# Gather information about printer queue's on system.
##################################################################################
# Defaults
PS3="Please select desired printer: "
fulllist="`cd /etc/lp/interface;ls`"
all_printers ()
{
hpnpadmin ${fulllist}
}
select_printer ()
{
select prtname in ALL Quit ${fulllist}
do
[ "${prtname}" = "Quit" ] && exit 0
if test -n "${prtname}"
then
if test "${prtname}" = "ALL"
then
prtlist="${fulllist}"
else
prtlist="${prtname}"
fi
break
fi
done
hpnpadmin ${prtlist}
}
[ "${select_on}" = 'N' ] && all_printers || single_printer
./jdpstatus[64]: single_printer: not found
# Main
if test ${#} -ne 0
then
while getopts :s option
do
case ${option} in
s) select_on="Y";;
?) echo "Usage: ${0} [<-s>]"
exit 4 ;;
esac
done
fi
exit 0
mvitux01@/home/fgrosb01#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 07:18 AM
тАО09-30-2002 07:18 AM
Re: Parameter help inside script.
"single_printer" is incorrect, it should be "select_printer".
I didn't actually mean to move the statement, just initialise select_on to "N", or whatever you need it to be at the beginning of the script.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 07:18 AM
тАО09-30-2002 07:18 AM
Re: Parameter help inside script.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 08:18 AM
тАО09-30-2002 08:18 AM
Re: Parameter help inside script.
Were extremely close, everything works with the exception of when you select #1) All
you get an error, (listed below).
Each of the individual printer queue names work as needed, but I also have no need to have model.orig as a listed variable there but I can deal with that if I had to. the big thing here is the ALL option which should print the necessary info for #'s 4-6 in one listing.
1) ALL
2) Quit
3) model.orig
4) mv2itd05
5) mv2itd07
6) mv2itd08
Please select desired printer: 1
model.orig: Unknown printer
: Error sending SNMP request.
*** Can't find the session!
mvitux01@/home/fgrosb01#
mvitux01@/home/fgrosb01# more jdpstatus
#! /usr/bin/ksh
# This script is utilized to gather printer information on all print queue's installed
# on a system using the hpnpadmin command.
# Environmental section
BASEDIR=/home/fgrosb01
DATE=`date +%m/%d/%Y`
YDATE=`TZ=CST+24 date +%m/%d/%Y`
SCRIPT_EXECUTION_TIME=$(date +'%H:%M:%S')
SCRIPT_REVISION="HPUX-b.11.00.01"
SCRIPT_HPUX_VERSION=$(uname -r)
SCRIPT_SYSTEM=$(uname - n)
SCRIPT_USER=$(whoami)
SCRIPT_EXECUTION_TIME=$(date +'%Y/%m/%d/%H:%M:%S')
echo $SCRIPT_SYSTEM \(Version $SCRIPT_REVISION\) $SCRIPT_EXECUTION_TIME
echo _____________________________________________________________________
echo
if [ ${SCRIPT_USER} != "root" ] ; then
echo
echo "This program must be executed utilizing the root logon id only"
echo
return 501
fi
echo _______________________________________________________________________
# Gather information about printer queue's on system.
##################################################################################
# Defaults
PS3="Please select desired printer: "
fulllist="`cd /etc/lp/interface;ls`"
all_printers ()
{
hpnpadmin -iqS ${fulllist}
}
single_printer ()
{
select prtname in ALL Quit ${fulllist}
do
[ "${prtname}" = "Quit" ] && exit 0
if test -n "${prtname}"
then
if test "${prtname}" = "ALL"
then
prtlist="${fulllist}"
else
prtlist="${prtname}"
fi
break
fi
done
hpnpadmin -iqS ${prtlist}
}
[ "${select_on}" = 'N' ] && all_printers || single_printer
# Main
if test ${#} -ne 0
then
while getopts :s option
do
case ${option} in
s) select_on="Y";;
?) echo "Usage: ${0} [<-s>]"
exit 4 ;;
esac
done
fi
exit 0
mvitux01@/home/fgrosb01#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 08:53 AM
тАО09-30-2002 08:53 AM
Re: Parameter help inside script.
fulllist="`cd /etc/lp/interface;ls`"
Did you know a directory called "model.orig" exists in that folder? This could cause an unknown printer error.
I have found when debugging a script to put some echo commands to display key variables at key points. That way I don't "assume" the values are what I expect.
Good Luck
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 09:24 AM
тАО09-30-2002 09:24 AM
Re: Parameter help inside script.
Once I changed the FULLIST directory to:
fulllist="`cd /etc/lp/interface/model.orig;ls`"
The script will now return a value for the ALL function, but it is only the 1st printer that is listed, not all of the printers in the directory. As in the above post by me, option 1=all, option 4-6 are the individual printers, now when you select option 1, it only returns the info on the 1st printer.
Any ideas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2002 09:59 AM
тАО09-30-2002 09:59 AM
Re: Parameter help inside script.
If you were to look at the man page for hpnpadmin, you would find it only allows one printer.
To work around, do the following
echo ${prtlist} | xargs -n1 hpnpadmin
This will run hpnpadmin once for each printer.
Another debugging hint-
If you have a command you are unfamiliar with, try running it directly to see the results, instead of "assuming" the command works the way you think it should.
HTH
-- Rod Hills