Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file  (Read 5367 times)

0 Members and 1 Guest are viewing this topic.

ata_nitjsr

    Topic Starter


    Starter
    batch file
    « on: February 12, 2009, 07:24:56 AM »
    I want to create a batch file which will do me a FTP the server has Login & password. How to pass login & password information through batch file ?

    PirateSamir



      Rookie

      Re: batch file
      « Reply #1 on: February 12, 2009, 07:39:48 AM »
      what?
      mind to rephrase that?
      Quantum bonus pro quantum numerus.

      gpl



        Apprentice
      • Thanked: 27
        Re: batch file
        « Reply #2 on: February 12, 2009, 08:11:17 AM »
        The way to do it is to put the ftp commands into a file -

        batch file
        Code: [Select]
        ftp -n -s:Login.ftp

        Login.ftp
        Code: [Select]
        open MyFTPSite
        user MyUserName
        MyPassword
        bin
        hash
        prompt off

        All these commands do is leave you at a command prompt to do what you want; you could of course script in any valid ftp command

        ata_nitjsr

          Topic Starter


          Starter
          Re: batch file
          « Reply #3 on: February 13, 2009, 04:04:40 AM »
          Hi gpl,
          I have tried with your code but got following error

          C:\Documents and Settings\XXXXXXX>ftp -n -s:Login.ftp
          Error opening script file Login.ftp.

          Transfers files to and from a computer running an FTP server service
          (sometimes called a daemon). Ftp can be used interactively.


          The Login.ftp code was

          open xxx.xxx.xxx.xxx(IP address)
          user user123
          Password123
          bin
          hash
          prompt off

          gpl



            Apprentice
          • Thanked: 27
            Re: batch file
            « Reply #4 on: February 13, 2009, 07:29:04 AM »
            The Login.ftp file has to be in the same folder as the one where you call it or you can put the full path in

            ftp -n -s:"c:\My FTP Files\Login.ftp"


            ata_nitjsr

              Topic Starter


              Starter
              Re: batch file
              « Reply #5 on: February 13, 2009, 10:44:14 PM »
              Hi,

              It is placed it in same folder,

              geting following error if i open a cmd then run the batch file by drag  & drop

              C:\Documents and Settings\xxxxx>ftp -n -s:Login.ftp
              Error opening script file Login.ftp.

              Transfers files to and from a computer running an FTP server service
              (sometimes called a daemon). Ftp can be used interactively.

              FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]

                -v             Suppresses display of remote server responses.
                -n             Suppresses auto-login upon initial connection.
                -i             Turns off interactive prompting during multiple file
                               transfers.
                -d             Enables debugging.
                -g             Disables filename globbing (see GLOB command).
                -s:filename    Specifies a text file containing FTP commands; the
                               commands will automatically run after FTP starts.
                -a             Use any local interface when binding data connection.
                -A             login as anonymous.
                -w:buffersize  Overrides the default transfer buffer size of 4096.
                host           Specifies the host name or IP address of the remote
                               host to connect to.

              Notes:
                - mget and mput commands take y/n/q for yes/no/quit.
                - Use Control-C to abort commands.

              C:\Documents and Settings\xxxxx>




              But i am geting following error when i directly run the batch file or go to the path and run it.

              F:\ata\Share>ftp -n -s:Login.ftp
              ftp> open xxx.xxx.xx.xxx
              Connected to xxx.xxx.xx.xxx.
              421 Unable to connect to remote server. Try again later.
              Connection closed by remote host.
              ftp> user user123
              Not connected.
              ftp> password123
              ftp> bin
              Not connected.
              ftp> hash
              Hash mark printing On  ftp: (2048 bytes/hash mark) .
              ftp> prompt off
              Interactive mode Off .
              ftp>


              But through a FTP tool i can to the PC.