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

In reply to Re: using pipes in a system() call by mcarlson
in thread using pipes in a system() call by mcarlson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.