FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 10th, 2004, 02:50 PM
kshah kshah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 kshah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How can I check all file are arrived via ftp

Can some one help with my problem with perl script. Since I my script need to wait for 12 files to arrived via (FTP or direct connect ). Currently, as soon as 12th files arrives it start processing. I need to wait and send email and wait ... until all files has a read/write permission.

attch it my script.



# GetNDMFiles.pl

$LOOP_MAX = 50;

$apl_dir = $ARGV[0];

# Initialize Variables
$pos_file = $apl_dir.'POSITION';
$prf_file = $apl_dir.'PERFORMANCE';
$cpr_file = $apl_dir.'CMBPERFORMANCE';
$txn_file = $apl_dir.'TRANSACTIONS';
$iss_file = $apl_dir.'ISSUETYPE';
$tns_file = $apl_dir.'TRANSTYPE';
$gl1_file = $apl_dir.'MONGOOSE1';
$gl2_file = $apl_dir.'MONGOOSE2';
$gl3_file = $apl_dir.'MONGOOSE3';
$sec_file = $apl_dir.'SECDATA';
$pmi_file = $apl_dir.'PMINFO';
$cmb_file = $apl_dir.'CMBCOMBINED';
$dummy_file = $apl_dir.'DUMMY';

$done = 0;
$got_pos = 0;
$got_prf = 0;
$got_txn = 0;
$got_iss = 0;
$got_tns = 0;
$got_gl1 = 0;
$got_gl2 = 0;
$got_gl3 = 0;
$got_sec = 0;
$got_pmi = 0;
$got_cmb = 0;
$got_dummy = 0;
$prf_cnt = 0;
$loop_cnt = 0;
$wait_cnt = 0;

#$root_path = "\\\\ENVCHID026\\apl_data\\";
$root_path = "\\\\PRODNDM1\\apl_data\\";

$bin_dir = $root_path."bin\\";
$file_dir = $root_path."rcv\\";
$load_dir = $root_path."load\\";
$rpt_dir = $root_path."rpt\\";
$arch_dir = $root_path."arch\\";

print "$file_dir \n";

open ( LOG_FILE, ">$rpt_dir$apl_dir".".log" );

while ( ! $done && ++$loop_cnt < $LOOP_MAX ) {

print "Check files \n";

print LOG_FILE "Check files \n";

opendir ( DIR_HAND, $file_dir );

while ( $file_name = readdir ( DIR_HAND ) ) {

if ( uc( $file_name ) =~ /$pos_file/ && ! $got_pos ) { $got_pos = 1; }
if ( uc( $file_name ) =~ /$prf_file/ && ! $got_prf ) { $got_prf = 1; }
if ( uc( $file_name ) =~ /$cpr_file/ && ! $got_cpr ) { $got_cpr = 1; }
if ( uc( $file_name ) =~ /$txn_file/ && ! $got_txn ) { $got_txn = 1; }
if ( uc( $file_name ) =~ /$iss_file/ && ! $got_tns ) { $got_iss = 1; }
if ( uc( $file_name ) =~ /$tns_file/ && ! $got_tns ) { $got_tns = 1; }
if ( uc( $file_name ) =~ /$gl1_file/ && ! $got_gl1 ) { $got_gl1 = 1; }
if ( uc( $file_name ) =~ /$gl2_file/ && ! $got_gl2 ) { $got_gl2 = 1; }
if ( uc( $file_name ) =~ /$gl3_file/ && ! $got_gl3 ) { $got_gl3 = 1; }
if ( uc( $file_name ) =~ /$sec_file/ && ! $got_sec ) { $got_sec = 1; }
if ( uc( $file_name ) =~ /$pmi_file/ && ! $got_pmi ) { $got_pmi = 1; }
if ( uc( $file_name ) =~ /$cmb_file/ && ! $got_cmb ) { $got_cmb = 1; }
# if ( uc( $file_name ) =~ /$dummy_file/ && ! $got_dummy ) { $got_dummy = 1; }

} # end while readdir

print $got_pos, $got_prf, $got_cpr, $got_txn, $got_iss, $got_tns, $got_gl1, $got_gl2, $got_gl3, $got_sec, $got_pmi, $got_cmb, "\n";

print getTime(), "\n";
print $got_pos, $got_prf, $got_cpr, $got_txn, $got_iss, $got_tns, $got_gl1, $got_gl2, $got_gl3, $got_sec, $got_pmi, $got_cmb, "\n";
print "$pos_file, $prf_file, $cpr_file, $txn_file,$iss_file, $tns_file, $gl1_file, $gl2_file, $gl3_file, $sec_file, $pmi_file, $cmb_file, \n";

closedir( DIR_HAND );

$done = $got_pos;

$done = $got_pos + $got_prf + $got_cpr + $got_txn + $got_iss + $got_tns + $got_gl1 + $got_gl2 + $got_gl3 +$got_sec + $got_pmi + $got_cmb;
print "$done files has arrived so far that why I need sleep. Currently the time is "; print getTime(), "\n";
if ( $done == 12 ) {


$done = 0;
print "SLEEPING \n";
sleep 3;

}
} # end while not done


if ((( -r $pos_file ) && ( -w $pos_file )) && (( -r $prf_file ) && ( -w $prf_file )) && (( -r $cpr_file ) && ( -w $cpr_file )) && (( -r $txn_file ) && ( -w $txn_file )) && (( -r $iss_file ) && ( -w $iss_file )) && (( -r $tns_file ) && ( -w $tns_file )) && (( -r $gl1_file ) && ( -w $gl1_file )) && (( -r $gl2_file ) && ( -w $gl2_file )) && (( -r $gl3_file ) && ( -w $gl3_file )) && (( -r $sec_file ) && ( -w $sec_file )) && (( -r $pmi_file ) && ( -w $pmi_file )) && (( -r $cmb_file ) && ( -w $cmb_file )))
{
print "$pos_file file does not have Read/White Permission at "; print getTime(), "\n";
sleep 1200;
}
print "$done $pos_file file has Read/white permission at "; print getTime(), "\n";


if ( $loop_cnt == $LOOP_MAX ) {
print "LOOP_MAX = ", $LOOP_MAX, "\n";
print "LOOP_CNT = ", $loop_cnt, "\n";

exit(1);
}


sub getTime
{

@test=localtime(time);

$hr = @test[2];
$min = @test[1];
$sec = @test[0];


if ( $hr < 10 ) { $hr = "0".$hr; }
if ( $min < 10 ) { $min = "0".$min; }
if ( $sec < 10 ) { $sec = "0".$sec; }

$cur_time = $hr.":".$min.":".$sec;


}

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > How can I check all file are arrived via ftp


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway