trendle has asked for the wisdom of the Perl Monks concerning the following question:
I'm searching for the parent directory containing a specific file type using File::Find. I then want to ls -l on that directory and redirect the output to APPEND into a named file somewhere.
The problem... I could create a string with the command for each directory (and that does the redirect), but... Some of the parent directory names contain shell meta chars (sometimes).
So if I read the system help correctly, I must use the args as an array to prevent shell meta char interpretation. Well that works. But now my redirect is broken. Now ls complains it can't find a file called '>>'
What do I do to fix this ?
# use File::Find; # find(\&get_this,"."); # sub get_this { if( -d $_ ) { opendir(DIZ,$_); DIREL: while( $del = readdir(DIZ) ) { if( $del =~ m/\.xxx$/ ) { print "$File::Find::name\n" ; $File::Find::prune = 1; system("echo \"----------------------------------------------- +--\" >> \"/Volumes/Expansion\ Drive/stuffTGZ/list_xxx_dirs.txt\""); system("echo \"- $File::Find::name --------------------------- +--\" >> \"/Volumes/Expansion\ Drive/stuffTGZ/list_xxx_dirs.txt\""); my @syscmd = ("/bin/ls","-l","$File::Find::name",">>","/Volume +s/Expansion\ Drive/stuffTGZ/list_xxx_dirs.txt") ; system(@syscmd); last DIREL; } } closedir(DIZ); } }
BTW, does it make any difference bieng on iMac OSX ? thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Another system redirect problem
by ikegami (Patriarch) on Jun 18, 2011 at 05:44 UTC | |
by Anonymous Monk on Jun 18, 2011 at 06:43 UTC | |
by ikegami (Patriarch) on Jun 18, 2011 at 09:38 UTC | |
Re: Another system redirect problem
by jwkrahn (Abbot) on Jun 18, 2011 at 07:13 UTC | |
by trendle (Novice) on Jun 18, 2011 at 21:40 UTC | |
Re: Another system redirect problem
by Anonymous Monk on Jun 18, 2011 at 05:31 UTC | |
Re: Another system redirect problem
by trendle (Novice) on Jun 18, 2011 at 18:11 UTC | |
by ikegami (Patriarch) on Jun 19, 2011 at 19:50 UTC | |
by trendle (Novice) on Jul 07, 2011 at 06:10 UTC |