Sponsored Content
Top Forums Shell Programming and Scripting File transfer from remote to local Post 303014623 by jim mcnamara on Friday 16th of March 2018 10:17:28 AM
Old 03-16-2018
I think you are asking: 'how to stop deletion of files on a file server until after the file has been copied'

One way: rename each file right after you copy it over.
You can do this several ways example using your current pid
Code:
# create a special local directory
pid=$$
local_dir=./myfiles/${pid}
test -d  $local_dir || mkdir $local_dir
cd $local_dir
sftp someplace.com
username password
cd /path/to/files
mget files*
bye
find . -type f -name |
while read fname 
do
         sftp someplace.com <<EOF
         username password
         cd /path/to/files
         rename "$fname" "$pid"
         bye
EOF
        mv "$fname" /path/to/permanent_local_storage/directory
        rm "$fname"  # get rid of local duplicate. 
done
sftp someplace.com <<EOF
  username password
  cd /path/to/files
  rm "$pid"
bye
EOF

Your remote directory has one file left because you kept renaming every file you copied to a pid number. Remove it when you are done. This can be improved in lots of ways.

Note: the EOF that ends a heredoc in this example has to be LEFT i.e., column 1

EDIT: I see Rudi had the same idea.
It can float if the first one for the heredoc is <<-EOF
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SCO Openserver 6 Remote File Transfer

Hi, I have a server which has SCO Openserver 6 on it and also kermit installed, unfortunately I can't seem to get kermit to send or receive files, is there another way I can use to transfer files remotely? I only have remote access to the server via a dial up modem Any comments/suggestions... (1 Reply)
Discussion started by: Martyn
1 Replies

2. HP-UX

Transfer file from local unix server to remote server

want to remove the thread thanks (2 Replies)
Discussion started by: indira
2 Replies

3. Shell Programming and Scripting

Transfer file from local unix server to remote server

want to remove this thread. thanks (2 Replies)
Discussion started by: indira
2 Replies

4. UNIX for Dummies Questions & Answers

File System - Remote or Local??

Is there a way to find if the file systems mounted on a AIX/Linux box is local or remote? (1 Reply)
Discussion started by: Un1xNewb1e
1 Replies

5. HP-UX

How to execute a remote file with local command

Hello, I know this is somewhat strange, but please let me know if possible. I want to execute a program file in the remote machine with command on the local machine. Let me make things more clear. Suppose I have a cc on my local system and do not have that on the remote system. I want to use... (2 Replies)
Discussion started by: Veera_Raghav
2 Replies

6. UNIX for Dummies Questions & Answers

How to transfer file from Local PC to Unix Directory without FTP!!!

Dear Friends, How to transfer files from my local PC to Unix directory without using FTP. Scenario: Transfer/Upload a file from PC to unix using web browser without using FTP technologies. I heard something like sendunix and sendpc used to transfer files from unix to Desktop and... (1 Reply)
Discussion started by: kk_c2il2
1 Replies

7. Shell Programming and Scripting

How to transfer file from Local PC to UNIX Directory without FTP?

Dear All, i am trying to get the file from windows location to unix location without using FTP and neither thru entering the user id and password. I have one unix form which is running on web application and user is entering the location and file name there now i know the file name and path. So i... (8 Replies)
Discussion started by: ripudaman.singh
8 Replies

8. UNIX for Dummies Questions & Answers

Transfer image file from local to remote with sftp

Hi. I have managed to transfer a file from remote to my raspberry pi, but I have the camera mounted on the Raspbien so I would like to transfer the image the other way. I use this line: sshpass -p 'PASSWORD' scp -- USER@ssh.servername.com:/www/cam/image.jpg /home/pi/shared/web/image.jpg (4 Replies)
Discussion started by: brickglow
4 Replies

9. UNIX for Dummies Questions & Answers

Remote file transfer between Linux and Windows

Hello, I have a file, say details.txt on my windows machine. I want to copy it to linux machine through a shell script and edit the file and transfer the file back to windows machine. (All I want to do is to edit the file on windows machine from linux machine by a script.) I have tried scp... (1 Reply)
Discussion started by: Devendra Hupri
1 Replies

10. UNIX for Advanced & Expert Users

Best way to transfer files to remote FTPS server instead of local FTPS server

Hi, I am working on an application which runs on an Informatica Red-Hat 5.10 Linux Server. The application involves several Informatica ETL workflows which generate 100s of Text files with lot of data. Many of the files will each be up to 5 GB in size. Currently the Informatica server itself... (7 Replies)
Discussion started by: waavman
7 Replies
rpdump(1)						      General Commands Manual							 rpdump(1)

NAME
rpdump - pine remote data utility SYNTAX
rpdump [ -f ] -l Local_file -r Remote_folder DESCRIPTION
Rpdump may be used to copy the actual data from remote Pine configuration files or address books into a local file. It is intended to be used by system administrators. Regular users should normally use the facilities provided within Pine. Local_file will normally be a local temporary file. Remote_folder is the IMAP folder being used as a remote Pine configuration (with the help of Pine's -P, -p, and -x commands or PINECONF, PINERC, and PINERCEX environment variables) or remote Pine address book folder. A copy of the data from Remote_folder will be copied to Local_file. -f Force the dump even if the remote folder is in an unrecognized format. -l Local_file The file on this system that is to be copied to. -r Remote_folder A remote folder name to be copied from. See the Pine documentation for the syntax of a remote folder name. One exam- ple is {my.imap.server}remote_pinerc. DIAGNOSTICS
Exit status is zero if all goes well, -1 otherwise. SEE ALSO
Rpload(1). Copyright 1989-2001 by the University of Washington. Pine and Pico are trademarks of the University of Washington. $Date: 2001/10/01 19:24:03 $ rpdump(1)
All times are GMT -4. The time now is 04:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy