Perl and Quotas

Discussion in 'Perl Misc' started by John Call, Feb 16, 2004.

  1. John Call

    John Call Guest

    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
     
    John Call, Feb 16, 2004
    #1
    1. Advertising

  2. John Call

    Ben Morrow Guest

    "John Call" <> wrote:
    > 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 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";
    > ---------------
    >
    > Quota::query returns the following error:
    > Unable to query quota for 2977:No such process


    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

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
     
    Ben Morrow, Feb 16, 2004
    #2
    1. Advertising

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

    <snip>
    >
    > 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.
     
    James Willmore, Feb 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,840
  2. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    323
    PerlFAQ Server
    Jan 23, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    712
    PerlFAQ Server
    Feb 3, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    316
    PerlFAQ Server
    Feb 27, 2011
  5. Dilbert
    Replies:
    0
    Views:
    859
    Dilbert
    Nov 10, 2011
Loading...

Share This Page