The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ftp code in Perl Raynon Shell Programming and Scripting 21 09-11-2008 03:44 AM
need help to write perl code getdpg Shell Programming and Scripting 0 09-20-2006 09:24 AM
perl code help circleW UNIX for Dummies Questions & Answers 1 11-09-2004 05:28 PM
Perl running C code gdboling Shell Programming and Scripting 1 09-02-2003 06:43 PM
Perl Code Hiding sskb Shell Programming and Scripting 5 01-02-2002 02:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2008
talashil talashil is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 59
PERL Code

I have a code block ...

$cmd = "find $audit_dir -mtime +$days_to_keep -exec rm {} \\;";

unless(open(CMD, "$cmd |")){
$msg = "Error command : $cmd \n\n";
print_log $lgh,"$msg",1;
exit 1;
}

print_log $lgh, "Deleting physical files with Command : $cmd ", 1 if verbose;

while ($line=<CMD>) {
print_log $lgh, "Physical files older than $days_to_keep deleted from $audit_dir", 1 if $verbose;
}


after it executes the print_log , it's not going inside the while loop ..

what am I missing here ?

Thanks
  #2 (permalink)  
Old 06-05-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
turn on warnings and rerun your code:

use warnings;

might help point out some problems in your code
  #3 (permalink)  
Old 06-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If the find command doesn't print anything, you obviously won't be getting any input on the <CMD> handle. (Why would you want to print the log message once per output line if there were many lines of output, anyway?)

I guess you're trying to divine the exit status of the find command; the close should tell you that, or simply use system instead of open
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0