Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Spectraflame wrote:

Currently the log file is being populated each time when the script is ran. Is there a way to truncate the log after X number of days so it does not continue to grow?

You can rotate the log file after a certain size:
https://winscp.net/eng/docs/commandline#logging
Spectraflame

Currently the log file is being populated each time when the script is ran. Is there a way to truncate the log after X number of days so it does not continue to grow?
Spectraflame

It did work after I corrected my spelling mistake. I was referencing a local directory that did not exist. Now I just need to find a way to send an email with the transfer status and this should be complete.
martin

I've meant manually from Windows command-line, not from Task Scheduler.
Spectraflame

I ran it manually from within Windows and the Task Scheduler log output stated it completed however no data was transferred. I created a test task just to see if WinSCP would open from the scheduler and it did. I then placed just the /script portion of the argument but it did not run. Is the " before the C:\ causing the issue? Is that necessary? There is also nothing being placed in the WINSCP.LOG file. Should the script be placed in the argument before the script to output to the log file?

It works fine if the log file part of the script is removed. Is the syntax wrong? I would like to have some type of log history of the transaction. Can that be accomplished in a single file?
martin

For a start, execute it manually.
Do you get any errors, when you try that?
Spectraflame

I created what I thought was correct. Can anyone see any issues with this syntax? I tried to schedule it through Windows Scheduler but it did not run successfully.

# Connect to FTP Server using credentials
open sftp://USERNAME:PASSWORD@FTP_SITE.com/ -hostkey="ssh-rsa 2048 XX:XX:XX:XX/k="

# Locate Local PC Directory
lcd C:\METERING
cd /

# Upload Data
put *

# Disconnect from FTP
close

# Close WinSCP
exit

# Execute the script using a command like:
# "C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\TMP\GDS_LOG\WinSCP.log" /ini=nul /script="C:\TMP\UPTEST.txt"
Spectraflame

Automate FTP from Windows PC

This is all new to me so forgive my ignorance. I have a local folder in the root of the C: drive of a Windows 10 PC. I would like to automate an FTP transfer to an external location. Where do I begin? Do I need to create a saved connection within WinSCP? Is there specific syntax necessary to automate this? Is it run from within WinSCP or controlled by a related batch file? Are there examples available to reference? This will be something that will run everyday at a specific time and transfer a single file using the same file name each day and overwrite the previous file on the destination.