Help with script to transfer files from one server to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with script to transfer files from one server to another
# 1  
Old 12-07-2015
Help with script to transfer files from one server to another

Hi

I have the following script:
Code:
#!/bin/sh
set -x
touch -mt 201210040000 /tmp/ref1
touch -mt 201210042359 /tmp/ref2
find /fs1/bscsrtx/BSCS_ix/WORK/LOG -type f \( -newer /tmp/ref1 -a ! -newer /tmp/ref2 \) > file_lst
scp $(< file_lst) root@10.100.48.76:/ano2005/fs1_2015/LOG/

but somehow its giving me the following error:

Code:
+ touch -mt 201210040000 /tmp/ref1
+ touch -mt 201210042359 /tmp/ref2
+ find /fs1/bscsrtx/BSCS_ix/WORK/LOG -type f ( -newer /tmp/ref1 -a ! -newer /tmp/ref2 )
+ 1> file_lst
find: cannot stat /fs1/bscsrtx/BSCS_ix/WORK/LOG
+ 0< file_lst
+ scp root@10.100.48.76:/ano2005/fs1_2015/LOG/
Usage: scp [options] [[user@]host1:]file1 [...] [[user@]host2:]file2


Pls can I have help on this
# 2  
Old 12-07-2015
Looks like find is complaining that directory
Code:
/fs1/bscsrtx/BSCS_ix/WORK/LOG

does not exist.

Please confirm.

Regards
Peasant.
# 3  
Old 12-07-2015
in the source:

Code:
#pwd
/fs1/bscsrtx/BSCS_iX/WORK/LOG

in the destination:

Code:
 pwd
/ano2005/fs1_2015/LOG

# 4  
Old 12-07-2015
There is a difference in the provided output and script..
Code:
/fs1/bscsrtx/BSCS_ix/WORK/LOG
/fs1/bscsrtx/BSCS_iX/WORK/LOG

The devil is in the details.

Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 5  
Old 12-07-2015
yes there was a typing mistake, but now its only sending one file,as opposed to more that 100 files in that directory:

Code:
#./transf
+ touch -mt 201210040000 /tmp/ref1
+ touch -mt 201210042359 /tmp/ref2
+ find /fs1/bscsrtx/BSCS_iX/WORK/LOG -type f ( -newer /tmp/ref1 -a ! -newer /tmp/ref2 )
+ 1> file_lst
+ 0< file_lst
+ scp /fs1/bscsrtx/BSCS_iX/WORK/LOG/13853006.log root@10.100.48.76:/ano2005/fs1_2015/LOG/
Password:
13853006.log                                                                                                                100% 3280     3.2KB/s   3.2KB/s   00:00

# 6  
Old 12-07-2015
Is the content of the file_lst populated with 100 of files ?

Check the content of the file and verify that.
Be sure to examine the output of scp, you might hit ARG_MAX limit with this kind of action on that number of files.

Regards
Peasant.
# 7  
Old 12-07-2015
you are right, there is onely 1 file inside
Code:
/tmp/fr/file_lst

!!
but I´ve used the markers
Code:
/tmp/fr/ref1

and
Code:
/tmp/fr/ref2

with a timestamp....

---------- Post updated at 02:24 PM ---------- Previous update was at 02:13 PM ----------

its now working fine, I have decreased the markers
Code:
touch -mt 201210040000 /tmp/ref1
touch -mt 201210092359 /tmp/ref2

One query:

After transferring, how can I delete the transferred files in the source server.
Does a simple
Code:
rm $(< file_lst)

will work?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Not able to transfer files using between server A and B

Hi All, I have generated public and private pair to avoid to enter password manually while sending files through sftp. But still I am facing issues and every-time prompt asking enter password. Below are steps I fallowed to make ssh connection between two servers. 1. Generated public and... (5 Replies)
Discussion started by: renukeswar
5 Replies

2. Shell Programming and Scripting

Shell scripting to transfer files from one to another server through ftps

Hi Guyz ,, I'm an ERP functional guy , I really need to automate a script which required a shell script but have a little knowledge in shell scripting. I need my generated files to be zipped first in one directory lets say (xyz) and then it needs to transfer another ftp server in... (3 Replies)
Discussion started by: Shogundion
3 Replies

3. Shell Programming and Scripting

Transfer files from one server with bash script

Hello to all, I want to copy from one server to another files of last 24 hours with size between 500MB and 2GB. The code below searches last files in 24 hours. find . -mtime -1 In order to copy faster I'd like to compress the files before copying them. How to automate the process of... (8 Replies)
Discussion started by: Ophiuchus
8 Replies

4. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

5. 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

6. Shell Programming and Scripting

SFTP to transfer files from one server to another

Hello, i have to write a script to perform sftp from the remote server to another server. the files which are at the remote location are huge data log files which should be transfered to my server in a particular folder. could you please provide me the general code (simple )... (1 Reply)
Discussion started by: urfrnddpk
1 Replies

7. Shell Programming and Scripting

Help needed to transfer list of files to FTP server, to different folders

Hello Unix Gurus, Help required from you. My requirement is something like this I want to create a concurrenct program in Oracle Applications using shell script to transfer files from Apps Server to destination FTP server. I have created custom program, where I will extract all the... (4 Replies)
Discussion started by: amazon
4 Replies

8. Shell Programming and Scripting

Shell script to transfer the files from source to target server.

I need to write a shell script to transfer the files every hour from source - target server. The cron job should be running every hour and shouldn't copy already copied files to the remote server ? I was able to write intial script but not able to get the logic for (in the next run it should... (12 Replies)
Discussion started by: radhirk
12 Replies

9. Linux

transfer files from the server 1 to server 2

I want to transfer files from the server 1 to server 2, but only information available FTP my server 2 How? Is there a script help me in the transfer of files through FTP :( (2 Replies)
Discussion started by: bomozah
2 Replies

10. UNIX for Dummies Questions & Answers

Transfer files from Unix server to Windows using FTP

Dear Friend, I don't know much about unix.I am an VB6.0 Programmer.I need to move an text files as aaa.txt from unix server to windows "D: " driver using the FTP protocol.Is it possible to do this with help of unix shell script.If possible please give some sample codes. Please answer as early... (1 Reply)
Discussion started by: gjsaravanan
1 Replies
Login or Register to Ask a Question