I'm new to perl. I have a input file with pipe delimited lines which have server_name, and file names as fields. The file names have wild card (*) in the input feed file. The actual file names will be suffixed with timestamps.
Ex: Actual files in remote servers
server_1/abc_20110801.txt
server_1/abc_20110802.txt
server_1/abc_20110803.txt
server_2/xyz_20110801.dat
server_2/xyz_20110802.dat
Ex: Input feed file
server_1|abc_*.txt
server_2|xyz_*.dat
I'm trying to ssh to the remote servers and read the file and capture the timestamps of the 'latest' file (in this case server_1/abc_20110803.txt and server_2/xyz_20110802.dat). ssh keys to all the remote servers are already setup so that we don't need to pass user id and passwords.
I'm able to do this if the files exists in the same server using the following:
my @list_files = map { chomp; $_ } (`ls -t $wild_f_nme`);
my $f_nme=$list_files[0];
my ($accesstime, $modtime, $createtime, $fsize) = (stat($f_nme))[8,9,10,7];
How would I do this to check the time stamps of files in remote servers. I need to initiate ssh connection for each of the servers.
FYI - I'm unable to (cannot) install any modules (like Net::OpenSSH). Can we accomplish this with using something like ?
my @list_files = map { chomp; $_ } (`qx/ssh $serv_nme ls -t $d_loc/$wild_f_nme`);