I am trying to create a script to batch mark a user group as privileged in RT. I found a script on the RT RT wiki to add users to a group and provide them with privileged status, and then delete the bits associated with adding to the group. Perl script I have the following left:
#!/usr/bin/perl
I have users in the file, one username per line. I don't know perl yet, so I tried to create a small bash script to skip the file and run the perl script once for each name. bash script, what it looks like right now:
#!/bin/bash touch commands.sh cat usernames.txt | while read LINE ; do N=$((N+1)) echo /home/chris/RT/bin/rt_set_privileged.pl \"$LINE\" >> commands.sh /home/chris/RT/bin/rt_set_privileged.pl \"$LINE\" perl /home/chris/RT/bin/rt_set_privileged.pl \"$LINE\" perl -w /home/chris/RT/bin/rt_set_privileged.pl \"$LINE\" eval /home/chris/RT/bin/rt_set_privileged.pl \"$LINE\" perl "/home/chris/RT/bin/rt_set_privileged.pl $LINE" done echo "Processed $N users"
As you can see, I tried several methods to run this command, but to no avail. Itβs annoying that I can take any of the commands from the command.sh file and paste them directly into the terminal without problems, this works great. When they run through a bash script, although I just get a bunch of these messages:
[Tue Sep 4 07:43:56 2012] [critical]: _AddMember called with a parameter that not an integer. (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:912) [Tue Sep 4 07:43:58 2012] [warning]: Use of uninitialized value $principal in pattern match (m//) at /var/www/ticket.ourcompany.com/lib/RT/Group.pm line 970. (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:968) [Tue Sep 4 07:43:58 2012] [error]: Group::HasMember was called with an argument that isn't an RT::Principal or id. It (undefined) (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:973) [Tue Sep 4 07:43:58 2012] [warning]: Use of uninitialized value $principal in pattern match (m//) at /var/www/ticket.ourcompany.com/lib/RT/Group.pm line 970. (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:968) [Tue Sep 4 07:43:58 2012] [error]: Group::HasMember was called with an argument that isn't an RT::Principal or id. It (undefined) (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:973) [Tue Sep 4 07:43:58 2012] [warning]: Use of uninitialized value in concatenation (.) or string at /var/www/ticket.ourcompany.com/lib/RT/User.pm line 341. (/var/www/ticket.ourcompany.com/lib/RT/User.pm:341) [Tue Sep 4 07:43:58 2012] [critical]: User is neither privileged nor unprivileged. something is drastically wrong. (/var/www/ticket.ourcompany.com/lib/RT/User.pm:341) [Tue Sep 4 07:43:58 2012] [warning]: Use of uninitialized value $new_member in pattern match (m//) at /var/www/ticket.ourcompany.com/lib/RT/Group.pm line 911. (/var/www/ticket.ourcompany.com/lib/RT/Group.pm:911)
assuming the command runs without any parameters. At this point, I could run the command once for each user during the time I was trying to solve it, can anyone help?
source share