FTP - Get the file date and time on the remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP - Get the file date and time on the remote server
# 8  
Old 06-28-2005
Maybe using tar is not a pefect solution, but it is a robust one, I think.
# 9  
Old 06-28-2005
Nope. The file is an encrypted file and they post as is. Cannot compress the file and we do not have access to make any changes on the remote server.
# 10  
Old 06-28-2005
how about this(under ftp prompt)
Code:
quote MDTM <filename>

# 11  
Old 06-28-2005
FTP - Get the file date and time on the remote server

quote MDTM <filename>.
This gives just the date and time and filesize but does not show the filename. Does not get the required file with date and time from remote server.
# 12  
Old 06-28-2005
MySQL FTP - Get the file date and time on the remote server

Well, Thank you and appreciate for all of your support. One of my friend has provided a solution in 'perl' which works as I needed. Posting the script for those who are in need of getting the date and time while doing FTP. This script can be run if you have perl installed. The script is as follows:

#!/usr/bin/perl
#
# file date modify
# 6/28/05
# ver 1.0.1
#

use Date::Manip;
use Net::FTP;

$sourcedir = "filepath";
$filename1 = "filename";
$login = "remote server userid";
$passw = "remote server password";
$server = "remote server name";

$ftp = Net::FTP->new("$server");
$ftp->login($login,$passw);
$ftp->cwd($sourcedir);
@fileinfo = $ftp->dir($filename1);
$ftp->get($filename1);
$ftp->quit;

($accesstime, $modtime) = (stat($filename1))[8,9];

print $modtime . "\n";

$modtimeconv = localtime($modtime);

$datestr = UnixDate($modtimeconv, "%A, %B %e at %i:%M%p");

print "$datestr \n";

print $fileinfo[0] . "\n";

$dateinfo = substr($fileinfo[0], 45, 12);
print $dateinfo . "\n";

$finaldate = ParseDate($dateinfo);
$finaldate = $finaldate + 1;
$unixdate = UnixDate($finaldate,"%s");
print $unixdate . "\n";

utime($accesstime, $unixdate, $filename1);

#End of the perl script



Smilie Smilie Smilie
# 13  
Old 06-28-2005
Quote:
Originally Posted by gthokala
quote MDTM <filename>.
This gives just the date and time and filesize but does not show the filename. Does not get the required file with date and time from remote server.
The filename is already here. You can combine the filename and time in your script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read latest file name with a date and time and then download from FTP

Hi All, Please help. I have requirement to read the file / folder based on the latest date and download the file and folder. There will be files and folders in the location like 20140630-144422 20140630-144422.csv 20140707-182653 20140707-182653.csv 20140710-183153... (7 Replies)
Discussion started by: Praveen Pandit
7 Replies

2. Shell Programming and Scripting

FTP a File to a Remote Server

Hi, I'm fairly new to Linux and need help with a script to ftp a .csv file to a remote server. I can ftp the .csv file manually from my server to the remote server in the "/" location. When I execute the script I receive the following message Could not create file. Here's what I have for... (5 Replies)
Discussion started by: Computergal2104
5 Replies

3. Shell Programming and Scripting

FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi, Im using the following code for FTP #!/usr/bin/ksh ftp -v -n "10.29.45.11" << cmd user "mahesva" "mahesva123" get rtl.tar quit cmd Below is the log when i run the above code ********************************** Connected to 10.29.45.11. 220 (vsFTPd 2.0.1) 530 Please login with USER... (20 Replies)
Discussion started by: dll_fpga
20 Replies

4. Shell Programming and Scripting

How to FTP the latest file, based on date, from a remote server through a shell script?

How to FTP the latest file, based on date, from a remote server through a shell script? I have four files to be FTP'ed from remote server. They are of the following format. build1_runtime_mmddyyyy.txt build2_runtime_mmddyyyy.txt build3_runtime_mmddyyyy.txt buifile_count_mmddyyyy.txt ... (9 Replies)
Discussion started by: imran_affu
9 Replies

5. Shell Programming and Scripting

Pulling the file date from remote server

Hi, Can anyone please tell me whether we can pull the file from the remote server tru FTP, with the same date the file is available in remote server? Thanks, Punitha (1 Reply)
Discussion started by: puni
1 Replies

6. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

7. UNIX for Dummies Questions & Answers

to get remote server date & time

Hi, i dont have remote m/c user credential. i only know remote m/c ip address. and i am able to ping that remote m/c. In windows we use: "net time \\computername" to get the remote m/c time. so how can i get remote m/c time in unix m/c? (means a unix command) Thanks for the help. ... (9 Replies)
Discussion started by: partha_ori
9 Replies

8. UNIX for Dummies Questions & Answers

To ftp file on a remote server

I want to send some files in .gz format from my desktop to a remote server. What will be the procedure for that thanks (5 Replies)
Discussion started by: supercops
5 Replies

9. Shell Programming and Scripting

Contantly check for file at the remote server and ftp when avaliable

Hello, I used the search engine but could not find the solution I am looking for. Probably its simple but I do not know the solution. My requirement is I ftp files every day in the morning from the remote server to the local machine. Now if the files are not there at the time I schedule the ftp... (2 Replies)
Discussion started by: kiran_418
2 Replies

10. Shell Programming and Scripting

FTP a file to a remote Server

Dear all, I am trying to push a data file to a remote Server. I am taking date variable from the database. The file I want to push looks like this in /tmp hostname.export.beforedate.dmp.gz for reading the date from the database i have a file get_date.sql which contains select... (2 Replies)
Discussion started by: shivaraj
2 Replies
Login or Register to Ask a Question