Hi Chaps, I need bit more help with this, i slightly modified the code based on the inputs, still having the same issue of $_ substitution.
Appreciate your help with this. ################################################## #!/usr/bin/perl use strict; use warnings; my $base = "/usr/openv/netbackup/logs"; my @dirs = qw(bpcd bprd admin bpdbjobs bpsched nbdb user_ops bpbackup bpdbm bptm nbpushdata vmd bpbkar bphdb db_log tlhcd vnetd bpbrm bpjobd tlhd ); foreach my $dir1 (@dirs) { my @new= "$base/$dir1 \n"; foreach (@new){ system qq[(/usr/bin/find "$_" -mtime 3 -exec ls -l '{}' \\\;)] } } #################################################### error output /usr/bin/find: stat() error /usr/openv/netbackup/logs/bpcd : No such file or directory /usr/bin/find: stat() error /usr/openv/netbackup/logs/bprd : No such file or directory ######################################################### Kindly let me know why this error. Regds Js On Mon, Mar 29, 2010 at 4:35 PM, jet speed <speedj...@googlemail.com> wrote: > Many Thanks Simon, John and everyone else for pointing me to the correct > direction. Cheeers !! > Js > > On Fri, Mar 26, 2010 at 7:03 PM, Shlomi Fish <shlo...@iglu.org.il>wrote: > >> On Friday 26 Mar 2010 20:51:17 John W. Krahn wrote: >> > jet speed wrote: >> > > Hi, >> > >> > Hello, >> > >> > > I have a simple code below, >> > > >> > > ################################### >> > > #!/usr/bin/perl >> > > >> > > use strict; >> > > use warnings; >> > > >> > > my @list =( '/usr/data/logs' , '/usr/data1/logs'); >> > > foreach (@list) >> > > { >> > > print "$_ \n"; >> > > >> > > system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \;)"; >> > > } >> > > ################################################ >> > > >> > > I am not sure how to get the $_ value inside the system command, any >> tips >> > > would be most helpful. >> > >> > The escape \ in front of the semicolon is being interpolated away by >> > perl before the shell sees it so you need to escape it: >> > >> > system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \\\;)"; >> > >> >> 1. This is invalid Perl code - you cannot do "String"$_"OtherString". >> >> 2. \\\; has one redundant \ - you can use "\\;" inside a double quoted >> string >> instead. >> >> > Or you need to bypass the shell altogether: >> > >> > system '/usr/bin/find', $_, '-mtime', 3, '-print', '-exec', 'ls', '{}', >> > ';'; >> > >> > >> > (You do realize that "-print" and "exec ls {} \;" do the same thing?) >> > >> > >> > >> > John >> >> -- >> ----------------------------------------------------------------- >> Shlomi Fish http://www.shlomifish.org/ >> "Humanity" - Parody of Modern Life - http://shlom.in/humanity >> >> Deletionists delete Wikipedia articles that they consider lame. >> Chuck Norris deletes deletionists whom he considers lame. >> >> Please reply to list if it's a mailing list post - http://shlom.in/reply. >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> >> >