script for Copying files from one server to another using scp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for Copying files from one server to another using scp
# 1  
Old 09-10-2009
script for Copying files from one server to another using scp

Hi Scripting experts,

I am new to the unix scripting. Please help me out for solving the condition given below

I am trying to develop a script for Copying files which are getting generated in server A to server B using scp. In serverA files are generating as for eg abc1.txt, abc2.txt, abc3.txt.... . I need to append these file contents to a single file in ServerB. Whenever new files are getting generated in the ServerA those file content details need to be appended at the end of the single file in serverB.

Looking forward to hear from you alll

THanking you in anticipation

Rohith G
rohithji@gmail.com
# 2  
Old 09-10-2009
I can give you clues, on how to do.

1. Look for new files creation in ServerA.
[ Modules available in Perl to do that ].

2. Concatenate the files newly created to ServerB using cat command, in ssh command option.

There can be better ways to accomplish this..
# 3  
Old 09-11-2009
I'd use this way.

I would concatenate the info in a temporal file in server A, when you consider that the file is finished. you send with scp to server B .... and delete the file in server A.

I think , thats not the info you are looking for. In pseudo_code:

while (exit condition) {
if {new file created} { # test with ls output
cat new_file >> temporal_file
} else {
do nothing
}
scp ./temporal_file user@serverB:/path
rm temporal_file
# 4  
Old 09-11-2009
You could try something like:
Code:
cat abc[0-9]*.txt | ssh serverb "cat >> path-to-singlefile"

# 5  
Old 09-11-2009
Scp Script to copy files between servers

Hi Trutoman,

Thanks for your reply . I find this logic as a good one. since i m new to scripting can you please explain me in little bit more detail mannner on how to perform this

Regards,

Rohith G
# 6  
Old 09-11-2009
If you cant transform pseudocode in code you may consider move this post to Newbies Forum. You are supposed to code that script in this forum....or thats what i think. If dont Scrutinizer has code to you another way to do it.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automate splitting of files , scp files as each split completes and combine files on target server

i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies

2. Shell Programming and Scripting

Copying the files to Windows server from UNIX server

Hi Team, I had a requirement to write a shell script which automatically transfer the files from unix server to windows server. I can able to unix to unix using Scp command. I am not sure how to do unix to windows. I am very new on this concept. Could you please help me or guide in... (4 Replies)
Discussion started by: gvkumar25
4 Replies

3. UNIX for Dummies Questions & Answers

Copying files from one server to another

I need to copy huge set of data(files & floder) from one server to other. Can any one guide me.I have tried throught ftp mget but it is vain...floder are not moving...... Do suggest me any good method (12 Replies)
Discussion started by: kkalyan
12 Replies

4. Shell Programming and Scripting

Shell script for copying files from 1 server to other

Hi, I just need a shell script that copies a list of files from a directory in a remote server to my current directory at local server the remote server may contain the following list: /root/pradeep/myfiles/default /root/pradeep/myfiles/dir1 /root/pradeep/myfiles/dir2 ...... (1 Reply)
Discussion started by: paddu
1 Replies

5. Shell Programming and Scripting

Shell Script to connect to another server and copying files

Hi Unix Gurus, I have a doubt reg file transfer. I have used the below script to connect to another server and find files having modified for the last 24 hours and have to move the file to another server. While i tried i am getting authentication failed, destination path not found issue. ... (2 Replies)
Discussion started by: incepted
2 Replies

6. Shell Programming and Scripting

Error copying files from Unix (Solaris10) to Windows Server 2003 using scp/sftp

Hi, I have generated a Public/Private Key Pair in Solaris Unix (source) server and deployed the Public key in Windows 2003(target) server .ssh directory of user profile. When i try to connect(ssh, scp, sftp) from Unix, i'm getting below error message. Sun_SSH_1.1, SSH protocols 1.5/2.0,... (0 Replies)
Discussion started by: ajaykumarb
0 Replies

7. UNIX for Dummies Questions & Answers

Copying files to different linux machines using scp

Hi alll i had a file authorized_keys on machine one. now i need to copy this authorized keys file into machine2,machine 3..... i use scp authorized_keys root@192.168.168.11:/tmp/ for copying file . is there ant way to copy the same filr to multiple machines at one go ... (1 Reply)
Discussion started by: kalyankalyan
1 Replies

8. Shell Programming and Scripting

scp files from other server with check

Hi all, I am new to this forum,and it has been really a great pleasure to be a part of this forum:) well,i m trying to write a shell script where i m transfering a set of files from other server to my own server. for this i m using scp... (1 Reply)
Discussion started by: prasson_ibm
1 Replies

9. Shell Programming and Scripting

writing script in UNIX for copying files in two server

can anyone help me in writing script in UNIX for copying files in two server from the third server after checking the files in the third server and if there is anything new in the third server automatically it should be added to the rest of the two servers and if same file is existing in the two... (4 Replies)
Discussion started by: REKHA09
4 Replies
Login or Register to Ask a Question