Perl and Quotas

J

John Call

I am trying to write a small script that will change quotas for me on a
RedHat box. The following is my program (99% of which comes from the book
Perl for System Administration).
-----------
#!/usr/bin/perl

use Quota;

$filesystem = '/home/users/<username>';
$soft = 5;
$hard = 6;
$isoft = 0;
$ihard = 0;

my($name,$paswd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell ) =
getpwnam($ARGV[0]);

$dev = Quota::getqcarg($filesystem);

($curblock, $soft, $hard, $curinode, $btimeout, $curinode, $isoft, $ihard,
$itim
eout) = Quota::query($dev, $uid) or die "Unable to query quota for
$uid:$!\n";

Quota::setqlim($dev, $uid, $soft, $hard, $isoft, $ihard, 1) or die "Unable
to set quotas:$!\n";
---------------

Quota::query returns the following error:
Unable to query quota for 2977:No such process

If I REM out the Quota::query line, Quota::setqlim returns the following
error:
Unable to set quotas:No such file or directory

I'm really not sure why this is happening. I checked the errata page for the
book and found no errors for this section. I also check Google groups and
found nothing.

Any help appreciated.

Thanks,

John
 
B

Ben Morrow

John Call said:
I am trying to write a small script that will change quotas for me on a
RedHat box. The following is my program (99% of which comes from the book
Perl for System Administration).

use strict;
use warnings;
use Quota;

$filesystem = '/home/users/<username>';

my $filesystem = ...
$soft = 5;

my $soft = ...
$hard = 6;
&c.

$isoft = 0;
$ihard = 0;

my($name,$paswd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell ) =
getpwnam($ARGV[0]);

$dev = Quota::getqcarg($filesystem);

($curblock, $soft, $hard, $curinode, $btimeout, $curinode, $isoft, $ihard,
$itim
eout) = Quota::query($dev, $uid) or die "Unable to query quota for
$uid:$!\n";

Quota::setqlim($dev, $uid, $soft, $hard, $isoft, $ihard, 1) or die "Unable
to set quotas:$!\n";

This is an example of an Unhelpful Error Message (Not a typewriter!):
No such process is ESRCH, and the Quota docs say that Quota::query
fails with ESRCH if the user has no quota set. cf. Quota::strerr.

Ben
 
J

James Willmore

On Sun, 15 Feb 2004 23:29:21 -0500, John Call wrote:

Quota::query returns the following error:
Unable to query quota for 2977:No such process

If I REM out the Quota::query line, Quota::setqlim returns the following
error:
Unable to set quotas:No such file or directory

I'm really not sure why this is happening. I checked the errata page for the
book and found no errors for this section. I also check Google groups and
found nothing.

Are you *using* quotas on your system? With SuSE, you have the option to
use or not use quotas. And, a quick glance at the LPIC preperation book
shows there are a few commands that you can use to check the status of
quotas on your system (quotacheck, quotaon, etc.). Type in 'man -k quota'
for a list of commands to verify the quotas on your system.

In order to solve your Perl issue, you may want to check the system over
first. If you *have* enabled quotas, and they are being enforced, then
I'm not sure what's going on.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
7:30, Channel 5: The Bionic Dog (Action/Adventure) The Bionic
<Dog gets a hormonal short-circuit and violates the Mann Act
<with an interstate Greyhound bus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top