Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lpstat problems

Status
Not open for further replies.

desbo

IS-IT--Management
Oct 24, 2002
64
GB
When logged in as one user I get the following error if I do the command "lpstat" and not all the printers are displayed:

"/usr/lib/lpd/bsdshort[64]: /usr/bin/awk: arg list too long"

But logged in as different user it works OK and all printers are displayed.

What could be different about the user that works??

--------------------------------------------

Yes, I did post this last week but combined it with another problem. I had several replies to the other problem but none to this one.
 
No the Paths are the same
 
The shell's for the user's - specified in /etc/passwd - will be different; arg lists are expanded by the shell.

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
No, they are both set to
SHELL=/bin/ksh
 
Both users use the same binaries.
/usr/bin/lpstat
/usr/bin/awk
 
What OS is that?

Could you either post an entore '/usr/lib/lpd/bsdshort' OR maybe a block a code around line 64 if whis script.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Here it is.
OS version is 4.3.3 level 9
----------------------------------------------------

if [ &quot;$SHELL&quot; = &quot;/usr/bin/rksh&quot; -o &quot;$SHELL&quot; = &quot;/bin/rksh&quot; ]
then
DSPMSG=dspmsg
TR=tr
AWK=awk
else
DSPMSG=/usr/bin/dspmsg
TR=/usr/bin/tr
AWK=/usr/bin/awk
fi

if MSGSTRUN=`$DSPMSG qstat.cat -s 2 4 &quot;RUNNING&quot;`
then :
else MSGSTRUN=&quot;RUNNING&quot;; fi
if MSGSTQUE=`$DSPMSG qstat.cat -s 2 5 &quot;QUEUED&quot;`
then :
else MSGSTQUE=&quot;QUEUED&quot;; fi
if MSGSTRDY=`$DSPMSG qstat.cat -s 2 31 &quot;READY&quot;`
then :
else MSGSTRDY=&quot;READY&quot;; fi
if MSGDWN2=`$DSPMSG rem.cat 40 &quot;HOST_DOWN&quot;`
then :
else MSGDWN2=&quot;HOST_DOWN&quot;; fi
AQUE=$1
RQUE=$2
$TR -d '\0' | $AWK '
BEGIN {
#----Set the state machine to read in messages and header lines
STATE = 0
#----Read in the arguments sent from qstatus, set up variables
QNAME = &quot;'&quot;$AQUE&quot;'&quot; # First parameter is used for name of queue
RNAME = &quot;'&quot;$RQUE&quot;'&quot; # Second parameter is used for remote queue name
STATUS = &quot;'&quot;$MSGSTRUN&quot;'&quot; # Status used for active job on queue
HOSTDOWN = &quot;'&quot;$MSGDWN2&quot;'&quot; # Status saying host is not responding for some reason
}
{
#----If we are still in header section of remote status output...
if(STATE == 0) {
#----Unable to communicate with host.
if ($1 == HOSTDOWN) {
printf(&quot;%-7.7s %-5.5s %-9.9s\n&quot;,QNAME,RNAME,HOSTDOWN);
}
#----Empty queue, &quot;no entries&quot;
else if ($1 == &quot;no&quot;) {
STATUS = &quot;'&quot;$MSGSTRDY&quot;'&quot; # Empty queue, ready
printf(&quot;%-7.7s&quot;,QNAME) # Queue name
printf(&quot; %-5.5s&quot;,RNAME) # Remote queue name
printf(&quot; %-9.9s&quot;,STATUS) # Device status
printf(&quot;\n&quot;)
}
#----If we are at field descriptor section, dont print,
# and go on to status section, where the stuff we want is
else if ($1 == &quot;Rank&quot;) {
++STATE
}
#----Otherwise, print the line because the user might want to see it
else if (NF > 0) {
printf(&quot;%s: %s\n&quot;,QNAME,$0)
}
}
#----Otherwise, we are in the status info lines for the remote queue
else {
#----If a valid status line...
#----NOTE: The socket attaches a '\0' at the end of the qstatus
# output from the remote server. AWK interprets this as
# another line. Thus, we check the number of fields to
# insure a blank line is not printed.
if((NF > 0) && (($1 ~ /^[0-9]+[a-z][a-z]$/) || ($1 ~ /active/))) {
#----Do some massaging to necessary fields
$1 = substr($1,1,length($1) - 2)
BLOCKS = ($5 / 512) + 1
#----If in the first line of the status section, we want
# to print the queue and device names in the proper fields
if(STATE == 1) {
printf(&quot;%-7.7s&quot;,QNAME) # Queue name
printf(&quot; %-5.5s&quot;,RNAME) # Remote queue name
#----Otherwise, just leave space in the queue and device fields
} else {
printf(&quot;%-13.13s&quot;,&quot;&quot;) # Empty que and dev fields
}
#----Print the rest of the status fields
printf(&quot; %-9.9s&quot;,STATUS) # Dev status
printf(&quot;%4d&quot;,$3) # Job number
printf(&quot; %-19.19s&quot;,$4) # Files to print
printf(&quot; %-10.10s&quot;,$2) # User requesting job
printf(&quot;%5.1d&quot;,0) # Pages to print
printf(&quot; %2.1d&quot;,0) # Percentage printed
printf(&quot;%6.1d&quot;,BLOCKS) # No. of blocks to print
printf(&quot;%3.1d&quot;,1) # No. of copies
printf(&quot;%4.1d&quot;,$1) # Ranking of job
printf(&quot;\n&quot;)
#----Insure state machine says that we are now past first
# status line, and adjust output fields accordingly
++STATE
STATUS = &quot;'&quot;$MSGQUE&quot;'&quot;
}
}
}
'
 
> Here it is.
> OS version is 4.3.3 level 9

it would be nice to know WHAT operating system is that and not just a version of it.

Do you have other versions of 'awk' on this system? It maybe the version you're invoking is pretty old [as it is with Solaris's awk].

I don't quite understand this:

if [ &quot;$SHELL&quot; = &quot;/usr/bin/rksh&quot; -o &quot;$SHELL&quot; = &quot;/bin/rksh&quot; ]
then
DSPMSG=dspmsg
TR=tr
AWK=awk
else
DSPMSG=/usr/bin/dspmsg
TR=/usr/bin/tr
AWK=/usr/bin/awk
fi

Try changing it to:

if [ &quot;$SHELL&quot; = &quot;/usr/bin/rksh&quot; -o &quot;$SHELL&quot; = &quot;/bin/rksh&quot; ]
then
DSPMSG=/usr/bin/dspmsg
TR=/usr/bin/tr
AWK=/usr/bin/awk
else
DSPMSG=/usr/bin/dspmsg
TR=/usr/bin/tr
AWK=/usr/bin/awk
fi

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks for you help, but a couple of comments

This is the IBM:AIX forum so I ommited that it was AIX.

We have never touched bsdshort. The changes you are suggesting will make no difference as the shell is /bin/ksh.

There is only one awk - /usr/bin/awk.

I am going to upgrade the OS to the latest revision level - 11 and see if that cures the problem.
 
Actually, you're posting to the wrong forum - this is UNIX Scripting Forum and the OS is important in this respect.

What I don't understand (and it might be AIX specific) is why there's this 'if':
if [ &quot;$SHELL&quot; = &quot;/usr/bin/rksh&quot; -o &quot;$SHELL&quot; = &quot;/bin/rksh&quot; ]

what what EXACTLY gets piped into $AWK with this statement:

$TR -d '\0' | $AWK

I don't know - this is very confusing. You might have better luck at the AIX specific forum, but at the same time it's basic scipting issue.

Good luck!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
sorry about that. I could have sworn I click on the AIX forum when I started the thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top