Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com Mar 28 '13 at 22:32

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

2  
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
1  
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

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Mar 28 '13 at 17:24
    
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
    
Thanks a lot for your help. Will do that. –  Mowgli Mar 28 '13 at 19:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.