Issue with scp to whole folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue with scp to whole folder
# 1  
Old 09-10-2012
Issue with scp to whole folder

previously 1 folder was created in a week. but now it creating more than 1 folder. shown as belowfor
example:--------------------
1 Aug A
2 Aug B
8 Aug M.


Now i want scp to the whole content for whole folder. Let say in first week having 2 folder which need to scp to remaote in twice for each folder i,e A,B. similarly in second week we need to once in a week i,e M.but i need to automate the this manual work by schedule for each week.

Last edited by rabindratech; 09-10-2012 at 04:26 PM.. Reason: to more understanding
# 2  
Old 09-10-2012
You might look into 'rsync', which will keep the remote looking like the local, can use ssh.

You can make local and remote file lists with "find ... -mtime -N", sort them, compare them with 'comm -23' to get the new file names, and just scp those files. If file might change, you can use cksum to add the length and sum to the name and the same comm will see if they are new.
Code:
#!/bin/bash
 
cd wherever
 
comm -23 <(
   find * -mtime -2 -type f | xargs -r cksum | sort
  ) <(
   ssh -nC host_over_there 'cd wherever
     find * -mtime -2 -type f | xargs -r cksum' | sort
  ) | while read s l n
  do
   scp -C $n host_over_there:wherever/$n
  done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't solve a simple SSH/scp issue.. Please help.

Disclaimer: I tried searching but wasn't able to get to the answer so please don't flame. Scenario: I have a root script that generates a file on box1 and then needs to scp it over to box2 using user1. Both boxes are running open-ssh. root@locat-host# scp /tmp/file1 user1@box2:/tmp/file1 ... (10 Replies)
Discussion started by: denissi
10 Replies

2. Shell Programming and Scripting

SFTP GET Local folder issue

Hi, My requirement is that I should execute SFTP from /users/XYZ dir and get the file on to /users/XYZ/TEST folder with out the sys error. I'm facing the following strange issue with SFTP execution. I need to copy a file 'abc.txt' from Remote m/c(MyServer) to local machine(Server1). I've... (3 Replies)
Discussion started by: skpvalvekar
3 Replies

3. Shell Programming and Scripting

scp/untar .tar file in parallel issue

Hi Guys, I am facing a strange issue while doing parallel (using & for background) scp/untar operation from my unix box to multiple unix boxes... I am getting tar : unexpected EOF in archive error the code is as follows.,,, for i in 10 do sh -c "scp <command> ; ssh tar -xf <tar> -C... (4 Replies)
Discussion started by: mihirvora16
4 Replies

4. UNIX for Advanced & Expert Users

scp/untar in parallel issue tar : Unexpected EOF in archive

Hi Guys, I am facing a strange issue while doing parallel (using & for background) scp/untar operation from my unix box to multiple unix boxes... I am getting tar : unexpected EOF in archive error the code is as follows.,,, for i in 10 do sh -c "scp <command> ; ssh tar -xf <tar> -C... (1 Reply)
Discussion started by: mihirvora16
1 Replies

5. Solaris

scp issue

Hi I am trying to copy file from one server to another server. i used : scp filename username\@targerserver:path i got this is error : ssh: servername: node name or service name not known lost connection Please advice on this Thanks, Mani (1 Reply)
Discussion started by: Mani_apr08
1 Replies

6. UNIX for Dummies Questions & Answers

scp issue

I've got an ssh server on each pc in my LAN. I wanna use scp to copy files, but it doesn't work. 0;4:59pm% scp mghis@localhost:/home/mghis/foobar mghis@192.168.0.3:/home/mghis/foobar mghis@192.168.0.3's password: < I type in the remote password > mar 28 set 2010, 17.00.26, CEST 17:00:26 up... (4 Replies)
Discussion started by: mghis
4 Replies

7. UNIX for Dummies Questions & Answers

scp issue

hi, after scp from a mac to a unix server and back a set of .wav files (originally generated by ppt with 'record narration') become corrupted somehow, and when opened the sound files has become noise. non-.wav files in the same folder are not affected. strangely, the problem only seems to... (0 Replies)
Discussion started by: halcroves
0 Replies

8. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

9. UNIX for Dummies Questions & Answers

scp -r and "?" folder

Hi, I am using scp command to backup files and copy the entire directory from the remote server to backup folder on my local machine. Please see the command below: scp -r -p elenaa@host:../../folder1/folder2/ ./backup/ Everything transfers just fine however after the transfer is done... (2 Replies)
Discussion started by: ElenaA
2 Replies

10. Shell Programming and Scripting

Reg: SCP issue

Hi , I am beginner in aix... i am using the following command in my shell script to to copy the files from a secured server to my aix box... /usr/local/bin/scp pickme@brad.wanted.com:../internal/mem_grp_details* Should i use sleep command in my shell script for the script to copy the... (15 Replies)
Discussion started by: sam99
15 Replies
Login or Register to Ask a Question