Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    Kingston, Canada
    Posts
    118

    Perl: how to run a command line command from inside perl

    Hey all,

    I am trying to write a Prel script that will run on a Linux got for managing quotas. If you are at the command line in Linux you can use the command:
    'setquota username | groupname block-softlimit block-hardlimit...'
    What I am trying to do is automate this as there are many users to do and I want to be able to set this as a job as to update quotas if we want to change them.

    If I am and the command line I simply type in the command (setquota) with the proper informatin and its done. My question is, how do I run the command from inside my Perl script?

    Thanks.
    My site: redclaw.ca

  2. #2
    Join Date
    Jun 2005
    Posts
    697
    Code:
    system "what | ever --command >> $you$like";
    should work
    ReflexNetworks means Happy Clients!

  3. #3
    Join Date
    Mar 2004
    Location
    Kingston, Canada
    Posts
    118
    Just looked it up and that looks like I want. I had not gotten to that part of my book yet, was still 50 pages off. I tried looking at the table of contents but I did not know what I was looking for.

    Thanks.
    My site: redclaw.ca

  4. #4
    Join Date
    Oct 2005
    Location
    Quebec
    Posts
    60
    If you want to catch the output of the command line the quickest / easiest way to do it is by using the secret back ticks

    my $command_output = `command`;

    if command output isn't required use system, it's much more perlish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •