fluticasone has asked for the wisdom of the Perl Monks concerning the following question:
It is just that I need to change FILE timestamp without having to login every time. Since scripts are not secure in maintaning username/password; I have seen an answered given by the monks to use Net::FTP; without using a login information opening the directory (remote machine w/ IP) like a file
But opening the remote server like a file. Thus it requires time and specific information unless I do a quick search. I would like to know a routine to open this mode and not get kick-out with "connection close by remote server" message. Also estimated wait time on large files or logs are very hard to asses not impossible. I will thank any response by the monks.#!/usr/bin/perl use strict; my %count; my $directory = "\\Test"; opendir( DIR, $directory ) || die "Unable to open directory - $!\n"; my @files = grep /\.txt/, readdir( DIR ); closedir( DIR ); open( OUTFILE, ">> $directory\\COID_LIST.txt" ) || die "Unable to open write file! - $!\n"; foreach my $file (@files) { open( FH, "$directory\\$file" ) || die "Unable to open $file - $!\n"; while( <FH> ) { my $ID = substr( $_, 260, 5 ); print OUTFILE "$ID\n"; $count{$ID}++ if ( defined( $ID ) ); } close( FH ); } print "Number of company ID = " . scalar keys %count; sub process_files { if ($File::Find::dir ne $dir) { $File::Find::prune = 1; return 0; } return 0 if ($_ !~ /\.txt$/); copy($File::Find::name, "\\temp\\$_") or die "Failed to copy $_: $ +!\n"; return 1; } find(\&process_files, $dir); Sub renaming_files { foreach my $file (glob "*.old") { my $newfile = $file; $newfile =~ s/\.old$/.new/; if (-e $newfile) { warn "can't rename $file to $newfile: $newfile exists\n"; } elsif (rename $file, $newfile) { ## success, do nothing } else { warn " rename $file to $newfile failed: $!\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Open Remote Directory
by aitap (Curate) on Aug 23, 2012 at 12:38 UTC |