Re: Wrapping Unix Command into Perl

2003-12-12 Thread John W. Krahn
Anthony J Segelhorst wrote:
> 
> I am trying to wrap the following Unix command into perl and having a few
> issues:
> 
> find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls {}
> \;
> 
> I have tried (and nothing to seems to work):
> 
> $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print
> -exec ls {} \;`;
> system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print
> -exec ls {} \;`
> !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print
> -exec ls {} \;`;


use File::Find;

find( sub { /^DB_/ and -M > 10 and print }, '/var/spool/Tivoli/backups' );



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Wrapping Unix Command into Perl /correction

2003-12-12 Thread Jeff Westman

--- Jeff Westman <[EMAIL PROTECTED]> wrote:
> Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:
> > Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:
> > 
> > > I am trying to wrap the following Unix command into perl and having a 
> > few 
> > > issues:
> > > 
> > > find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls 
> > {} \;
> > > 
> > > 
> > > I have tried (and nothing to seems to work):
> > > 
> > > $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> > -exec ls {} \;`;
> > > system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> > -exec ls {} \;`
> > > !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> > -exec ls {} \;`;
> > 
> > Jeff Westman wrote:
> > >1-- You are useing parens '( )' and should be using curly braces '{ }' 
> > >in your exec.
> > >2-- Why are you using -exec ls?  -print already gives you the same output 
> > 
> > >(unless you meant to write 'ls -l')
> > 
> > 
> > 1.  I am using {} and not ()
> 
> Well, that is the problem then.  You have to use the curly braces.

My bad, {} and () look the same in the font type, sorry.  I tried your 
shell example and it worked for me (perl 5.8).

But as also mentioned, you really should try to avoid shelling out, and 
use File::Find and unlink().

> > 2.  Eventually I want to use this command to a remove rm, but I was 
> > testing with an ls.



__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Wrapping Unix Command into Perl

2003-12-12 Thread Jeff Westman
Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:
> Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:
> 
> > I am trying to wrap the following Unix command into perl and having a 
> few 
> > issues:
> > 
> > find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls 
> {} \;
> > 
> > 
> > I have tried (and nothing to seems to work):
> > 
> > $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> > system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`
> > !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> 
> Jeff Westman wrote:
> >1-- You are useing parens '( )' and should be using curly braces '{ }' 
> >in your exec.
> >2-- Why are you using -exec ls?  -print already gives you the same output 
> 
> >(unless you meant to write 'ls -l')
> 
> 
> 1.  I am using {} and not ()

Well, that is the problem then.  You have to use the curly braces.

> 2.  Eventually I want to use this command to a remove rm, but I was 
> testing with an ls.

ok

-Jeff

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Wrapping Unix Command into Perl

2003-12-12 Thread Wiggins d Anconia


> 
> Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:
> 
> > I am trying to wrap the following Unix command into perl and having a 
> few 
> > issues:
> > 
> > find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls 
> {} \;
> > 
> > 
> > I have tried (and nothing to seems to work):
> > 
> > $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> > system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`
> > !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> 
> Jeff Westman wrote:
> >1-- You are useing parens '( )' and should be using curley braces '{ }' 
> >in your exec.
> >2-- Why are you using -exec ls?  -print already gives you the same
output 
> 
> >(unless you meant to write 'ls -l')
> 
> 
> 1.  I am using {} and not ()
> 
> 2.  Eventually I want to use this command to a remove rm, but I was 
> testing with an ls.
> 

If all you are doing is a remove why not just do it in Perl with
File::Find and 'unlink'??

perldoc File::Find
perldoc -f unlink

Then you won't have to worry about all of the issues with shelling out

http://danconia.org


--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Wrapping Unix Command into Perl

2003-12-12 Thread Anthony J Segelhorst
Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:

> I am trying to wrap the following Unix command into perl and having a 
few 
> issues:
> 
> find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls 
{} \;
> 
> 
> I have tried (and nothing to seems to work):
> 
> $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`;
> system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`
> !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`;

Jeff Westman wrote:
>1-- You are useing parens '( )' and should be using curley braces '{ }' 
>in your exec.
>2-- Why are you using -exec ls?  -print already gives you the same output 

>(unless you meant to write 'ls -l')


1.  I am using {} and not ()

2.  Eventually I want to use this command to a remove rm, but I was 
testing with an ls.

Anthony J Segelhorst
Enterprise Systems Management Team
Phone: 937-495-1876
Email: [EMAIL PROTECTED]





Jeff Westman <[EMAIL PROTECTED]>
12/12/2003 03:58 PM

 
To: perl_help <[EMAIL PROTECTED]>
cc: 
Subject:Re: Wrapping Unix Command into Perl


Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:

> I am trying to wrap the following Unix command into perl and having a 
few 
> issues:
> 
> find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls 
{} 
> \;
> 
> 
> I have tried (and nothing to seems to work):
> 
> $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`
> !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;

1-- You are useing parens '( )' and should be using curley braces '{ }' 
in your exec.
2-- Why are you using -exec ls?  -print already gives you the same output 
(unless you meant to write 'ls -l')


-Jeff




__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




This email has been scanned for all viruses by the MessageLabs SkyScan
service.___





This email has been scanned for all viruses by the MessageLabs SkyScan
service.___

Note:  Please update your email address for this user to reflect the
new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
are in the format of [EMAIL PROTECTED] 

This electronic message contains information from MeadWestvaco
Corporation or subsidiary companies, which may be confidential,
privileged or otherwise protected from disclosure.  The
information is intended to be used solely by the recipient(s)
named.  If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this
transmission or its contents is prohibited.  If you have
received this transmission in error, please notify MeadWestvaco
immediately at [EMAIL PROTECTED]
___

Re: Wrapping Unix Command into Perl

2003-12-12 Thread Jeff Westman
Anthony J Segelhorst <[EMAIL PROTECTED]> wrote:

> I am trying to wrap the following Unix command into perl and having a few 
> issues:
> 
> find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls {} 
> \;
> 
> 
> I have tried (and nothing to seems to work):
> 
> $temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;
> system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`
> !system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
> -exec ls {} \;`;

1-- You are useing parens '( )' and should be using curley braces '{ }' 
in your exec.
2-- Why are you using -exec ls?  -print already gives you the same output 
(unless you meant to write 'ls -l')


-Jeff




__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Wrapping Unix Command into Perl

2003-12-12 Thread Anthony J Segelhorst
I am trying to wrap the following Unix command into perl and having a few 
issues:

find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print -exec ls {} 
\;


I have tried (and nothing to seems to work):

$temp = `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`;
system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`
!system `find /var/spool/Tivoli/backups -name "DB_*" -mtime +10 -print 
-exec ls {} \;`;

Anthony J Segelhorst
Enterprise Systems Management Team
Phone: 937-495-1876
Email: [EMAIL PROTECTED]


This email has been scanned for all viruses by the MessageLabs SkyScan
service.___

Note:  Please update your email address for this user to reflect the
new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
are in the format of [EMAIL PROTECTED] 

This electronic message contains information from MeadWestvaco
Corporation or subsidiary companies, which may be confidential,
privileged or otherwise protected from disclosure.  The
information is intended to be used solely by the recipient(s)
named.  If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this
transmission or its contents is prohibited.  If you have
received this transmission in error, please notify MeadWestvaco
immediately at [EMAIL PROTECTED]
___