Web Hosting Talk







View Full Version : Perl: how to run a command line command from inside perl


fozzy
10-28-2005, 09:37 AM
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.

andren
10-28-2005, 11:15 AM
system "what | ever --command >> $you$like";should work

fozzy
10-28-2005, 11:25 AM
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.

Eglis
10-28-2005, 11:34 AM
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.