# what is this command doing in batch file?

I have this command in .batch file.

Can someone explain me what it is doing?

ftp -d -s:c:/somefolder/file_xfer/ftpcmds.txt > c:/somefolder/file_xfer/xfer_prt.txt

I need to know because I am asked to change ftp to SFTP but I do not find SFTP in windows.

I found PSFTP from putty

Any feedback will be appreciated

Edit
xfer_prt file has following content

open SERVERNAME

prompt
cd /somedir/somedir2
CWD /somedir/somedir2
mput C:\somedir2\*
PORT ##,##,##,##,###,### (## some numbers I don't want to share.
STOR somefile.html
STOR Runner.flag
quit
QUIT

-

## migrated from stackoverflow.comMar 28 '13 at 22:32

This question came from our site for professional and enthusiast programmers.

Did you try ftp /? to see what the switches mean? -d prints extra debugging information, -s:path\to\ftpcmds.txt is a script telling ftp where to connect and what to do after connecting, and > path\to\xfer_prt.txt redirects the output of ftp from the console to a text log. –  rojo Mar 28 '13 at 14:17
I did ftp /? I understood -d but when it did -s but I don't understand where it is ftping to since it has path to local C:/ drive why use ftp ? –  Mowgli Mar 28 '13 at 14:33
You should post contents of c:/somefolder/file_xfer/ftpcmds.txt, because that's what matters. The file should contain FTP commands to connect, transfers, etc... –  Martin Prikryl Mar 28 '13 at 14:57
Thanks, I saw tht too, I after I follow the linking and the process of calling this ftp. it is opening someserver and logs in with user and pass. –  Mowgli Mar 28 '13 at 17:16
@MartinPrikryl Please see edit of xfer_prt.txt posted –  Mowgli Mar 28 '13 at 17:22

The -s parameter accepts a path to a local file that contains commands that will be passed one at a time to the ftp programme. In your case, the file ftpcmds.txt likely starts with something like this:

open ftp.domain.com

Windows does not have a built-in sftp client, so you will need to find a third-party client, but I would guess they would have a similar command-line feature. That will of course be completely dependent on the particular sftp app you choose.
The commands that get passed in to ftp from the text file are static and can't "adapt" based on whether there are errors during the transfer. So it's certainly easy to imagine it could get hung up, where ftp is expecting more commands but the calling process doesn't realize it. To figure out what's causing the hangup, you'll have to find a scenario that reproduces the problem every time, and then issue the commands manually instead of from the text file, and see what errors or unexpected results occur. –  Nate Hekman Mar 28 '13 at 19:38