Check files and archive the files using sftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check files and archive the files using sftp
# 1  
Old 10-27-2015
Check files and archive the files using sftp

Hi,
I have to check the files in another server using sftp to do that, below is the code i am going with
Code:
#!/bin/bash
export SRC_FOLDER=$1
export ARC_FOLDER=$2

HOST=as07u3456
USER=relfag

sftp ${USER}@${HOST} <<EOF
cd $SRC_FOLDER/DSCOR
ls 
bye
EOF
echo "done"

whatever the files i listed out, i want to place into ARC_FOLDER.
Please let me know how do i archive those files.

Thanks all
# 2  
Old 10-27-2015
Is ARC_FOLDER a local or remote folder?
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 10-27-2015
Yes. ARC_FOLDER is a remote folder.

Thanks

Last edited by ursrami; 10-27-2015 at 02:14 PM..
# 4  
Old 10-27-2015
use for loop
Code:
for f in SRC_FOLDER/DSCOR
do
mv $f /ARC_FOLDER/${f}
done

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and sample code.

Last edited by Don Cragun; 10-28-2015 at 04:06 PM.. Reason: Add CODE tags.
# 5  
Old 10-27-2015
That doesn't help when the source and dest are on a different machine...
# 6  
Old 10-28-2015
If both source and target are on the remote node, did you consider sftp's rename command?
# 7  
Old 10-28-2015
Yes I consider the sftp's rename command and its working if I explicitly given the filename like below
rename $SRC_FOLDER/DSCOR/w5src.csv $ARC_FOLDER/DSCOR/w5src.csv
it's OK. But I need to move all the files. The following didnt work
rename $SRC_FOLDER/DSCOR/*.csv $ARC_FOLDER/DSCOR/

Any suggestions.
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 archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. Shell Programming and Scripting

How to get CRC check sum of files in java EAR file without extracting .jar/.war files to disk.?

unzip -v gives CRC info of each file in a zip(in my case .EAR) file. # unzip -v my-application.ear Archive: my-application.ear Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 197981 Defl:N 183708 7%... (1 Reply)
Discussion started by: kchinnam
1 Replies

3. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

4. UNIX for Dummies Questions & Answers

How to archive old files from the recently added 10 files?

Hi there, I am very new to unix and having trouble with a fairly simple statement: cd /user ls -t -c1 | sed -ne '11,$p' | mv xargs archive/ What I want the code to do is sort all files in a directory by timestamp, select all of the files after the 10th file, and then move those files... (3 Replies)
Discussion started by: DSIReady
3 Replies

5. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

6. Shell Programming and Scripting

Kindly check it: Camparison of files only column1 of 2 files

Hi all, I have 2 files in which i have to find commom entries in column 1 an dif soemthing is common write other data of both files in front of it mentioned. Gene symbol and disease name column 1 column2 ARFGEF2 CAD DDEF2 CAD PSCD3 CAD PSCD4 CAD CAMK1... (15 Replies)
Discussion started by: manigrover
15 Replies

7. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

8. UNIX for Dummies Questions & Answers

Archive files that was already sftp'd/process

Hi, I need to modify my archive script to archive only files which is already sftp to the windows. We encounter some issue which the file is already archiving though it is not yet sftp'd to the Windows. Any answers.?Thanks! (1 Reply)
Discussion started by: sonja
1 Replies

9. Shell Programming and Scripting

Archive Files

I have 15-20 files in a unix folder on daily basis, so i need to archive those 20 files as dated today and place that archived files in a new folder and has to remove those 20 files from that folder. so that i place 20 new files that comes for tomorrow. i need write a unix script to do this. ... (1 Reply)
Discussion started by: gaddamshashank
1 Replies

10. Shell Programming and Scripting

Archive files

Hi All, I wrote this script: #!/bin/ksh while read DAYS ARCH_PATH do cd $ARCH_PATH find . \( -type d ! -name . -prune \) -o -type f -mtime +$DAYS -exec tar -cv f kay_`date +%d%m%y%H%M`.tar {} \; cd - done < filestoarchive.txt The problem is, in a folder of 7files, I would... (13 Replies)
Discussion started by: kayarsenal
13 Replies
Login or Register to Ask a Question