So here is the entire program, this is just a prototype but its just looking through the many home directories we have to find files owned by $UID, and chown's them to the new UID($NEWUID):
#!/usr/local/bin/perl
my $UID = 1202;
my $NEWUID = 51617;
my @home = ( "/home1/", "/home2/", "/home3/", "/home4/", "/home5/",
"/home6/", "/home7/", "/home8/", "/home9/", "/home10/",
"/home11/", "/home12/", "/home13/", "/home14/" );
my $i = 0;
foreach( @home )
{
opendir DH, $home[$i] or die "Cannot open $home[$i]: $!";
foreach $dir ( readdir DH )
{
next if $dir eq "." or $dir eq ".." or $dir eq ".snapshot" or
+$dir eq "TT_DB";
print "find $home[$i]$dir -user $OUN -print | xargs -n 1 chown
+ -h $NEWUID\n";
system("find $home[$i]$dir -user $OUN -print | xargs -n 1 chow
+n -h $NEWUID");
}
$i++;
}
the output is so:
find /home1/castillo -user 1202 -print | xargs -n 1 chown -h 51617
sh: syntax error at line 1: `|' unexpected
So the command I'm giving it prints out exactly as expected, and running that by hand does work. I guess I don't understand why a | is 'unexpected'. I did try `-print \; |` but that doesn't work either.
Thanks to all who replied.
Mike C
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.