Trying to put files on sftp but code below does not work.

March 26, 2015 at 21:35:27
Specs: Windows 7
%echo off


lcd C:\Users\chantal\Documents\DownloadedFilesFromBatchScript
cd /home/mysftpserver/Letters
mput "*.*"


See More: Trying to put files on sftp but code below does not work.

Report •

March 26, 2015 at 23:05:34
It interesting to know that it "does not work"

It might be helpful to know what it did; or didn't did.


M2 Get custom script or take private lessons

Report •

March 27, 2015 at 07:17:23
The commands to drive FTP must be stored in a separate script as you can see by the quick on-line help (type FTP -h). So try the following

@echo off
:: [Create FTP command script]
echo.lcd C:\Users\chantal\Documents\DownloadedFilesFromBatchScript /home/mysftpserver/Letters
echo.mput *
) > \ftp_cmd.txt

FTP -v -i -s:\ftp_cmd.txt

echo.Press any key to quit... & pause > nul

message edited by IVO

Report •

March 27, 2015 at 07:19:43
Were you able to connect? SFTP is not natively supported by Windows.
If you need to connect to SFTP servers, you can use 3rd party apps like WinSCP or PSFTP.

Report •

Related Solutions

March 27, 2015 at 09:59:53
I put IVO's code on one script. Got 'Access is denied'. Error opening script file \ftp_cmd.txt Not sure about the statement 'must be stored on separate script'

Report •

March 27, 2015 at 11:15:27
What I mean is the FTP instructions as username, password and other commands must be part of a specific text file (in the case I coded ftp_cmd.txt) NOT embedded in the batch script.

The statements embraced by parenthesis at the begin of the batch create that file that FTP reads by the switch -s: i.e. \ftp_cmd.txt. Why you get "access denied" is a mistery for me since I have tested the script and it works fine. The file ftp_cnd.txt is created in my script in the root of current unit. Try to view it by accessing via notepad, as I said it is a plain text file.

Report •

March 28, 2015 at 07:54:11
To complete my post #5 and pointing out what minimoto said in post #3, are you sure Access Denied is due to opening ftp_cmd.txt or is it caused by the (unsupported) SFTP server?

I tested the script on my own LAN and all worked fine, but the target is a FTP server.

Report •

Ask Question