Help with retrieving files via SFTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with retrieving files via SFTP
# 1  
Old 04-01-2016
Help with retrieving files via SFTP

I have a process which generates a file and places it on my sftp server

Then I connect to the sftp to retrieve the file. However for some reason, I keep getting an incomplete file.

These are the steps.

1. Submit a request to my sftp file to start generating a file
2. That file is picked up processed on a backend server and the output is placed back on the sftp server
3. Meanwhile my script keeps running frequently to check if the output file is present.
4. Once present it picks up the file

For some reason my process is picking up an incomplete file. Its like picking up the file whilst the output is getting transfered on the sftp server from the backend server.

Last edited by sidnow; 04-01-2016 at 04:32 PM..
# 2  
Old 04-01-2016
How do you make sure the creating process is finished generating the file?
# 3  
Old 04-01-2016
Quote:
Originally Posted by RudiC
How do you make sure the creating process is finished generating the file?
I can view that via a UI setup to monitor the same.
# 4  
Old 04-01-2016
Let's take for granted that sftp works flawlessly. So the problem must be somewhere else. If you say for sure the file is completely created, what are the differences that you find? Lines missing? At the end? other? Please post.
# 5  
Old 04-01-2016
And - "present" does NOT mean "complete", "finished"!
# 6  
Old 04-01-2016
The generating server could upload the file with a temporary filename and then, after upload is complete, rename it to the final name
Code:
sftp user@server.example.com
    put output output.tmp
    rename output.tmp output
    ....

This way, whenever your scripts find a file named output, you know, that the upload is complete.
# 7  
Old 04-01-2016
Quote:
Originally Posted by RudiC
Let's take for granted that sftp works flawlessly. So the problem must be somewhere else. If you say for sure the file is completely created, what are the differences that you find? Lines missing? At the end? other? Please post.
Sure.

My incomplete file gets truncated.

Only half the data is retrieved whereas on the sftp server, the entire file is present. I know that the entire file is present, because I compare the timestamp of the completed file on the sftp server, with the timestamp of my scripts pull. They match.


The data is missing towards end of the file. There are some garbage characters.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Retrieving names of files in a dir without overlapping

Hi, I have been trying to retrieve the names of files present in a directory one by one but the names of files are getting overlapped on one another. I tried the below command. ls -1 > filename please help me in getting the file names line by line without overlapping. I am using korn... (6 Replies)
Discussion started by: Pradhikshan
6 Replies

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

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

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

5. Solaris

help retrieving files from SunOS 5.8

Hi, I am trying to get a small amount of files off of a SunBlade 2000 running SunOS 5.8, but I'm having trouble finding a medium that will actually work. It is not networked, and it doesn't have a writable CD drive. My only options seem to be floppy disk and USB drive. However, when I insert... (11 Replies)
Discussion started by: ryanm
11 Replies

6. Shell Programming and Scripting

Retrieving files from print queue

Hi, wonder if anyone can help me out with this. I'm trying to retrieve files from a print queue on a remote server i.e. get files before they are printed. I'll be using perl to do this. I've written out some pseudocode below: Telnet to print server for ever (endless loop) pause 1 second... (0 Replies)
Discussion started by: Vovin
0 Replies

7. UNIX for Dummies Questions & Answers

retrieving files which has more than 0 bytes

Hi, Can anyone tell how to list all files in current directory which has more than 0 bytes? (4 Replies)
Discussion started by: sri2005
4 Replies

8. UNIX for Dummies Questions & Answers

Retrieving deleted files

I mistakenly deleted a script from the UNIX server. Is there any command i can type that i will retrieve my script? (3 Replies)
Discussion started by: manna
3 Replies

9. UNIX for Dummies Questions & Answers

Retrieving multiple files by date

Hey all, need help with finding multiple files just by the last date modified in all subdirectries in the current directory. Ex. Root directory/multiple directories say 0-99/ multiple files Need to find all files last modified from say ....01 1 2006. Is this possible? Thanks for any... (1 Reply)
Discussion started by: fantazle
1 Replies

10. AIX

retrieving files from Tape

I have AIX5.1 I have tried to retrieve a file from tape with no sucsess. I had this posted in the newbies section but I think I should have tried here. I did get some good info there though on where to start. This Is what I did. My back line is so... cat /rd/tmp/backuplist.full | cpio -ocvBdum... (1 Reply)
Discussion started by: rocker40
1 Replies
Login or Register to Ask a Question