I need SFTP to create remote directories via command line

Advertisement

unabletostay
Guest

I need SFTP to create remote directories via command line

Hi,

I'm using 5.1.3.0 via command line on a growing number of servers to backup a specific location. I'm using a Windows environmental variable %computername% so minimise customisation of the script per server.

I'm finding that when attempting to transfer to /%computername%/Data that because the /%computername% doesn't exist it fails. This makes sense and from my understanding this is by design. Is there however any switches I can use to change this so it does create the directory?

Script below:

winscp.com /log=log.txt /script=backupScript.txt    

backupScript.txt

option batch abort
option confirm off
open username:password@server
synchronize remote -delete "E:\Data" "/%computername%/Data"
exit    

Thanks in advance for your help. :)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,271
Location:
Prague, Czechia

Re: I need SFTP to create remote directories via command line

option batch continue
mkdir /%computername%/Data
option batch abort    

But you still get an error exit code and error record in the log.

Clean solution would be to use Session.FileExists from WinSCP .NET assembly:
https://winscp.net/eng/docs/library_session_fileexists
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum