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

Author Topic: how to create log file  (Read 3657 times)

0 Members and 1 Guest are viewing this topic.

rihan

    Topic Starter


    Greenhorn

    how to create log file
    « on: March 17, 2009, 10:30:58 PM »
    hi
    i have write following ftp script to upload file in server


    username
    pass
    bin
    hash
    prompt
    lcd filepath
    mput *.*
    this is text file to name test and batch file is


    ftp -s:test.txt servername
             
    exit

    the script is ok but i have crate log file to the output of  how to run of this bat file
    can any one help
    thanks is advance

    BatchRocks



      Hopeful
    • Thanked: 3
      Re: how to create log file
      « Reply #1 on: March 18, 2009, 04:51:35 AM »
      Code: [Select]
      >>Logfile.txt
      Put that at the end of your lines to go to that.

      rihan

        Topic Starter


        Greenhorn

        Re: how to create log file
        « Reply #2 on: March 18, 2009, 05:53:03 AM »
        thank for replay
        but this is not work
        the error is invalid command

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: how to create log file
        « Reply #3 on: March 18, 2009, 06:11:12 AM »
        put it at the end of your ftp command.
        I was trying to dereference Null Pointers before it was cool.

        rihan

          Topic Starter


          Greenhorn

          Re: how to create log file
          « Reply #4 on: March 18, 2009, 09:16:32 PM »
          yes i have write the end of the line
          but the error is invalid command

          username
          pass
          bin
          hash
          prompt
          lcd filepath
          mput *.*
          >>logfile.txt

          ghostdog74



            Specialist

            Thanked: 27
            Re: how to create log file
            « Reply #5 on: March 18, 2009, 09:59:11 PM »
            If you want to have more error control for your FTP script ,  you can
            1) use a better FTP to offers you options such as debugging or verbose output.
            2) use a better language such as Python(or Perl) which comes with FTP libraries with error control
            Code: [Select]
            from ftplib import FTP
            import os
            def upload(ftp, file):   ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
            os.chdir("localpath")
            ftp = FTP('localhost')
            ftp.set_debuglevel(3)  # <------------------------ set debugging mode.
            try:
                ftp.login("user","pass")
            except Exception, e:
                print "error ",e   #<---------------------------- this part will execute is login fails
            else:
                for files in os.listdir("."):
                    if os.path.isfile(files):
                        upload(ftp,files)

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: how to create log file
            « Reply #6 on: March 19, 2009, 10:05:54 AM »
            yes i have write the end of the line
            but the error is invalid command

            username
            pass
            bin
            hash
            prompt
            lcd filepath
            mput *.*
            >>logfile.txt


            at the end of your ftp command:

            ftp -s:test.txt servername >> logfile.txt

            I was trying to dereference Null Pointers before it was cool.