Article Figure 1 Listing 1 Listing 2 Listing 3
Listing 4 Listing 5 Listing 6 Listing 7 Listing 8
Listing 9 Listing 10 oct2005.tar

Listing 10 srm_user2project - An example script to dynamically move the processes owned by a user into a project

#!/usr/perl5/5.6.1/bin/perl

use strict;
use warnings;

my $user=$ARGV[0] || die "Please specify a user\n";
my $project=$ARGV[1] || "user.$user";
my $pid;

open(LIST,"ps -u $user -o pid |");
while(<LIST>){
        next if /PID/;
        chomp;
        $pid=$_;
        print "Moving process $pid to project $project...\n";
        system("newtask -v -p $project -c $pid");
}
close(LIST);