How to rename file in FP server with server time stamp?


 
Thread Tools Search this Thread
Operating Systems HP-UX How to rename file in FP server with server time stamp?
# 1  
Old 11-30-2011
How to rename file in FP server with server time stamp?

Hello All,

I am new user in this forum. Facing problem when trying to download file using Perl ::NET:FTP module.

I need to rename the remote server file with latest timestamp of that ftp server. Can somebody help me if this is possible?

Many thanks,
# 2  
Old 11-30-2011
it has the rename method.

Code:
$ftp->rename("one.xml", "two.xml")

# 3  
Old 11-30-2011
Hello Raj,

Sorry but i know this but i need to rename the existing file with FTP server current time stamp.
# 4  
Old 11-30-2011
you can put one dummy file. and get that dummy file date by using the below code.

Code:
 use strict;
use warnings;
use Net::FTP;
use File::Listing qw(parse_dir);
use POSIX qw(strftime);
my ($host, $user, $passwd) = ('a.b.org', 'me', 'pgrx%sf');
my $dir = '/some/dir';
my $ftp = Net::FTP->new($host)
    or die qq{Cannot connect to $host: $@};
$ftp->login($user, $passwd)
    or die qq{Cannot login: }, $ftp->message;
$ftp->cwd($dir) 
    or die qq{Cannot cwd to $dir: }, $ftp->message;
my $ls = $ftp->dir();
foreach my $entry (parse_dir($ls)) {
    my ($name, $type, $size, $mtime, $mode) = @$entry;
    next unless $type eq 'f';
    my $time_string = strftime "%Y-%m-%d %H:%M:%S", gmtime($mtime);
    print "File $name has an mtime of $time_string\n";
}
$ftp->quit;

How can I get the timestamp of a file on a FTP server?
# 5  
Old 11-30-2011
Thanks Raj,

I can understand this but is any other direct way to get current time for that server.
# 6  
Old 12-02-2011
Hello,

Closing the thread as i am unable to get the proper solution for the time being..

Thanks to all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transfer file from a server takes long time

It takes 6 hrs for a 90 GB zip file that i am copying / transferring from serverA onto serverB. scp user1@serverA:/opt/setup/cash.zip . Output: cash.zip 21% 19GB 4.7MB/s 4:11:46 ETA uname -a SunOS serverB 5.11 11.2 sun4v sparc sun4vCan you please suggest if i could do... (11 Replies)
Discussion started by: mohtashims
11 Replies

2. Shell Programming and Scripting

How to preserve time stamp while copying a directory from Server B to Server A?

Experts, Please help me out here. How to preserve time stamp while copying a directory from Server B to Server A (3 Replies)
Discussion started by: ahmed.vaghar
3 Replies

3. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

4. Solaris

Test program running taking much more time on high end server T5440 than low end server T5220

Hi all, I have written the following program and run on both T5440 and T5220 on same OS version. I found that T5540 server takes more time than T5220. Please find below the details. test1.cpp #include <iostream> #include <pthread.h> using namespace std; #define NUM_OF_THREADS 20... (17 Replies)
Discussion started by: sanjay_singh85
17 Replies

5. Shell Programming and Scripting

Create file base on server time

Hi Guys, Server time:- >date >Wed Nov 14 11:56:23 EST 2012 I want to convert in to Below Formet :- 20121114.1100 And cretae file base on above data : last 48 Hour 20121114.1000 20121114.1100 20121114.0900 20121114.1000 20121114.0800 20121114.0900 20121114.0700 20121114.0800... (2 Replies)
Discussion started by: asavaliya
2 Replies

6. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

7. Linux

rename files in a folder with date&time stamp

Hi, I want to rename all the files (more than 100 files) in a fodler to another folder with date&time stamp. foe eg, file1.dat file2.dat file3.dat .. to be renamed as file1100629_16_30_15.txt (yy-mon-dd_hh_mi_ss) file1100629_16_30_16.txt .. so on (2 Replies)
Discussion started by: feroz
2 Replies

8. Shell Programming and Scripting

how to pass time stamp of a file from one server to another......

We have a requirement wherein we have two servers namely A and B. Now we have to find out all the files in server B from a given location which have a timestamp greater than a file in server A. Subsequently we need to concatenate the contents of all these files and replace the same with the file... (3 Replies)
Discussion started by: jasonb
3 Replies

9. Shell Programming and Scripting

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

I would like to know if there is a way to get the date and timestamp of the file that is being FTP from the remote server using shell script. Currently the get command from FTP will have current date and timestamp. Tried the earlier suggestion 'HardFeed' but still getting the current date and time... (12 Replies)
Discussion started by: gthokala
12 Replies

10. Shell Programming and Scripting

rename file on a different server

Hello Every One. I am trying to put a timestemp file to a sever with extention file*.ia ( file*.ia is a time stemp and compress file ). Then rename it into file*.gz. My .netrc contant are : machine xxxx login xxxx password xxxx macdef init lcd /test/system cd /infolder ascii... (2 Replies)
Discussion started by: shah2
2 Replies
Login or Register to Ask a Question