I have found several references to appending data to existing files with WinSCP but I have been unable to get it to work. I'm technical enough to be dangerous but I can follow directions so I hope somebody can give me the steps I need to make so that I can follow them.
My goal is as follows:
- Write log data to a file called
log.txt
on a Windows server
- Automatically upload
log.txt
to a remote SFTP server using WinSCP triggered by a timed event
- Once the file is uploaded, a process on the remote server will automatically grab and delete the remote
log.txt
file
- After upload, the local script will delete the
log.txt
file on the Windows machine
The process I listed above can be handled easily but, if the remote process has NOT grabbed and deleted the
log.txt
file before the local process is automatically triggered again, I will overwrite the remote file, causing data loss.
If the remote
log.txt
file already exists on the SFTP server, I need to be able to append whatever new data is contained in the log.txt file on the local Windows machine to the existing
log.txt
file on the remote server.
Example:
log.txt
file on remote server contains:
log.txt
on the local server contains:
I want to append the data from the local file I am sending to the remote file so the end result is a log.txt
file on the remote server that contains:
1111
2222
3333
4444
5555
6666
7777
I hope I explained this clearly.
I have been digging around in the forums for an answer and I see instructions that get me close but I am hoping somebody can clearly document the steps I need to take to make this happen.
Thank you for your time and I look forward to your answer.
J