what is this command doing in batch file?

0

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

USER username

PASS passwordhere
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

Mowgli

Posted 2013-03-28T14:12:56.597

Reputation: 250

2Did 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 – 2013-03-28T14:17:49.647

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 – 2013-03-28T14:33:35.847

1You 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... – None – 2013-03-28T14:57:27.873

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 – 2013-03-28T17:16:05.253

@MartinPrikryl Please see edit of xfer_prt.txt posted – Mowgli – 2013-03-28T17:22:07.457

Answers

2

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
username
password
put file.txt
...
quit

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.

Nate Hekman

Posted 2013-03-28T14:12:56.597

Reputation: 136

Thanks Nate, that's what exactly is in that ftpcmds file, but the problem is sometimes ftp processes get stuck in windows server. it doesn't close as it should itself meaning gets hung in task manager any solution for this? – Mowgli – 2013-03-28T17:24:25.797

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. – None – 2013-03-28T19:38:26.703