perl script to transfer newly generated files by scp


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users perl script to transfer newly generated files by scp
# 1  
Old 10-13-2011
Question perl script to transfer newly generated files by scp

Hi all,

I have root directory on server 1 say A and having sub directory B now my application generates output files and put in sub directory B.
now i need to transfer these files from server1 to server2 by scp which is having same directory structure A and sub directory B
I have tried a lot but seems need ur guidance.


Code:
STAMP=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time() - 3600);
printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')
touch $STAMP /A/B
find /A/B -type f ! -newer /A/B -print -exec scp -r {} server2:/A/B/{} \; | tee -a ./output.txt


Last edited by pludi; 10-13-2011 at 09:17 AM..
# 2  
Old 10-17-2011
Try
Code:
find /A/B -type f ! -newer /A/B -print -exec scp -r {} server2:{} \;

If that doesn't work, try this as a way of debugging:

Code:
find /A/B -type f ! -newer /A/B -print -exec echo scp -r {} server2:{} \;

# 3  
Old 10-17-2011
Code:
# tar cf - dirA | ssh remotehost " ( cd /some/path ; tar xf - ) "

Will pipe tar'd dirA and dirB if sub directory of dirA and untar it on remote host.
This is also handy if there is not enough space on disk to tar on localhost.

Regards
SRG
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's I've a requirment to grep for a string in series of log files that are getting generated almost every minute. I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes. Please... (3 Replies)
Discussion started by: rajivatnova
3 Replies

2. Shell Programming and Scripting

Script to multi-transfer splitted files via scp

Hey :3 I am moving some stuff between different servers. I do it like this: scp -r -P 22 -i ~/new.ppk /var/www/bigfile.tar.gz user@123.123.123.123:/var/www/bigfile.tar.gz Lets say, this file is 50 GiB. I would like to know, if its possible to split the file in different parts,... (2 Replies)
Discussion started by: Keenora
2 Replies

3. UNIX for Advanced & Expert Users

SCP File Transfer

On unix AIX server, when I am trying to transfer file from one directory to another directory on the same server through a program(where i call the script) it gives error "Lost Connection". (5 Replies)
Discussion started by: Pash
5 Replies

4. UNIX for Advanced & Expert Users

SCP File Transfer

I have 3 AIX server namely - Server 1 , Server 2 and Server 3. And have done SCP setup between Server 1 and Server 2 so that i dont have to give password when i transfer file from Server 1 to Server 2 by setting public key between the server. Q1. If the unix password of the target server... (3 Replies)
Discussion started by: Pash
3 Replies

5. UNIX for Advanced & Expert Users

Transfer only modified files by SCP

Hi all, I want to transfer only modified files from one unix server to another unix sever ,tried hard but not succeeded please help me out to resolve it. The script is as below :wall: ssh user@hostname <<EOT >files.txt cd /x/y find . -mtime -0 -type f |\ while read file do echo $file... (8 Replies)
Discussion started by: tushar_spatil
8 Replies

6. Shell Programming and Scripting

SCP During Transfer to SunOS

Hi, I'd like to seek your help in finding the cause of this problem. I utilize SCP command to transfer files from one server to another. I utilize the return code that SCP return so as to verify if transfer is ok or not. Below is a sample code that I created. if scp... (9 Replies)
Discussion started by: padi
9 Replies

7. Shell Programming and Scripting

Problem while scp if bashrc calls Perl script

A weird thing, happened today: When i do SCP from a remote server, file is not getting copied to here. Application Server: Here is where i work, and have a login. I have several tweaks in .bashrc, and along with all those, today i called a PERL script from bashrc. So when ever i do scp from a... (4 Replies)
Discussion started by: thegeek
4 Replies

8. UNIX for Dummies Questions & Answers

File transfer using SCP

I have a shell script which uses SCP command to transfer the files from one server to another server. The files are getting transferred successfully, but the problem is the files transferred to the destination server didnot have the permissions as that of the files on the source server. Command... (5 Replies)
Discussion started by: kumarm
5 Replies

9. Shell Programming and Scripting

file transfer using scp..

Hi Frdz I have a problem like. I need to transfer a file from source to destination (different systems with different IPs) using "scp" command and before transfer the file i have to check the file is available in destination or not, if it is there no need to transfer, otherwise we have to... (5 Replies)
Discussion started by: KiranKumarKarre
5 Replies

10. Shell Programming and Scripting

How to scp as different user in perl script

Hi, I am writing a perl script that needs to change to a another user and scp files to a remote server. The passwords should not be prompted but read from a config file. Please help. Thanks Sandeep (4 Replies)
Discussion started by: sdubey
4 Replies
Login or Register to Ask a Question