Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found