Help with SFTP on directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with SFTP on directories
# 1  
Old 06-06-2013
Help with SFTP on directories

Hi Junta,

please help me with SFTP on remote directories.

i want to get the latest generated directory and its contents from remote machine to local host using SFTP. is there any possible way to achive this?? please help me. i feel its a bottle neck for meSmilieSmilie
# 2  
Old 06-06-2013
If your sftp supports ls -t, I might try this:

Code:
sftp username@host <<EOF > dirlist
ls -t /path/to/remotefolder
EOF

LATEST="$(head -n 1 dirlist)"

sftp username@host <<EOF
mget /path/to/remotefolder/${LATEST}/*
EOF

rm dirlist

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

2. Shell Programming and Scripting

Copy Directories with Files from One Server to Other using sftp

Hi, I have a requirement where I have to connect to another server and copy directories from one server to another Directories on the Source server look like below (YYYY-MM-DD- 1 to 23) drwxr-xr-x 2 test_user dmfmart 422 Sep 1 23:45 2014-09-01-18drwxr-xr-x 2 test_user dmfmart ... (1 Reply)
Discussion started by: arunkesi
1 Replies

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

4. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

5. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

6. UNIX for Dummies Questions & Answers

Moving files between directories using SFTP

I want to connect to an SFTP server, GET some files, then move those files to a different directory on the SFTP server so I don't try to GET them next time. But there doesn't seem to be a way to move files between directories on the remote server from SFTP. I missing something obvious? And if... (6 Replies)
Discussion started by: cjhancock
6 Replies

7. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

8. UNIX for Dummies Questions & Answers

help uploading directories with SFTP

Hi, I am a newbie and not really familiar with commands, I have searched the forum, but there was only one thread. That thread suggested compressing it and then decompressing it. So I am wondering, what format do I compress it to, and how do I decompress it once I uploaded it from within SFTP... (4 Replies)
Discussion started by: greetea
4 Replies

9. Shell Programming and Scripting

uploading directories via SFTP

Hello All, Is there a way to upload whole directories to a machine using sftp (scp is not an option)? I have to use sftp because the machine that I am connecting to only has SFTP abilities (uploading from a linux box to a windows box). Currently I am automating a copy however right now I am... (2 Replies)
Discussion started by: mab623
2 Replies
Login or Register to Ask a Question