0

I want to create a batch file to execute below commands -

  1. cd to the directory whose content i want to upload.
  2. log into the Ftp with Host name + userid & pswd
  3. Cd to the directory [in server] where you want to upload the files.
  4. mput *.txt

I am able to run these steps and transferred all the files to server location manually.

But now i want to automate the process, below is code of my batch file..but its giving error Invalid command - even though i have added linebreak after usernamevalue. i referred to How to script FTP upload and download?

i use below script - and its says "password required for user1" although i have given password

    @echo off
    echo user user1> ftpcmd.dat
    echo mypassword>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat myservername
    del ftpcmd.dat
    pause

also first i have to change the directory to the location from where i am picking all the files [source folder of my files]

Something like CD c:\MySource

Community
  • 1
  • 1
Code's
  • 208
  • 2
  • 18
  • Where are you getting the error message? Did you try stepping through the script to see where it occurs? Also, what does this have to do with C#? – Reticulated Spline Nov 07 '14 at 12:57
  • If you read the comments to the [answer you copied for your code](http://stackoverflow.com/a/936227), you'll see the note to remove the `user` before username, making your second line `echo user1 > ftpcmd.dat`. – Ken White Nov 07 '14 at 14:17
  • After removing 'user' from the command - its says "invalid command" – Code's Nov 07 '14 at 14:20

0 Answers0