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

Author Topic: copying two text files using at command  (Read 13886 times)

0 Members and 1 Guest are viewing this topic.

pkranthi

    Topic Starter


    Rookie

    Re: copying two text files using at command
    « Reply #15 on: February 06, 2008, 06:45:14 AM »
    What is the command to always start the copying of the second file in the first file in a new line.

    Thanks,
    kranthi

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: copying two text files using at command
    « Reply #16 on: February 06, 2008, 07:35:08 AM »
    Could you re-phrase your question? Are you saying it doesn't? I was under the impression the when copying multiple files, they were appended in sequence (left to right) to the output file.

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    pkranthi

      Topic Starter


      Rookie

      Re: copying two text files using at command
      « Reply #17 on: February 06, 2008, 08:09:12 AM »
      Yes they are appending from left to right but some times copying the second file to first file is done in the last line of the first file. But what I need is the second file should be copied in the new line after the last line of the fisrt file.

      I got a new porblem today when I tried the same thing on the network drive. my sample.bat which the copy command is in the c: directory. (c:\sample.bat)

      in the sample.bat the code is like this. (j is network drive)

      copy /b "J:\Risk Management\a1.txt" +"J:\Risk Management\a2.txt" "J:\Risk Management\a1.txt"

      in the command promt when I type the following command.

      c:\sample.bat (same bat file with command to copy the files on the j drive)

      This works, but the same thing if I am trying to do it with at it is not working and the command is as follows

      at 9:51am c:\sample.bat. This is not wrking and when I went to the log it says something like this

      "At1.job" (sample.bat)
         Finished 2/6/2008 9:51:00 AM
         Result: The task completed with an exit code of (1).

      exitcode(0) and exitcode(1) what is the difference?

      How to make the at work when trying to copy files on the network drive.

      Thanks,
      kranthi


      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: copying two text files using at command
      « Reply #18 on: February 06, 2008, 08:25:57 AM »
      Debugging can be very frustrating, especially when you can't see anything. In your batch file, put a pause statement after the copy. This should hold open the window and let you view any error messages.

      A reasonable guess is that exitcode(0) is OK, exitcode(1) is fail. What was in the status column of the scheduler?

      Not to be obvious, but do you have a connection to the J: drive?

       8)






      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      pkranthi

        Topic Starter


        Rookie

        Re: copying two text files using at command
        « Reply #19 on: February 06, 2008, 09:35:57 AM »
        I used the pause in the bat file and this is the result.

        -----Running bat file with out at.

        C:\>sample.bat

        C:\>copy /b "J:\Risk Management\a1.txt" +"J:\Risk Management\a2.txt" "J:\Risk Ma
        nagement\a1.txt"
        J:\Risk Management\a1.txt
        J:\Risk Management\a2.txt
                1 file(s) copied.

        C:\>pause
        Press any key to continue . . .

        ------with at.

        C:\>at 11:30am c:\sample.bat
        Added a new job with job ID = 1

        after this when I go the scheduler it still says running after 5 minutes and the log is like this.

        "At1.job" (sample.bat)
           Started 2/6/2008 11:30:00 AM
        [ ***** Most recent entry is above this line ***** ]

        Any suggestions...
        kranthi

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: copying two text files using at command
        « Reply #20 on: February 06, 2008, 11:51:29 AM »
        Quote
        Any suggestions...

        Not a one.  :(

        If I understand all this, it worked yesterday on a local drive using the scheduler; it doesn't work today on a network drive using the scheduler; but it works today on a network drive not using the scheduler.

        Just for kicks try scheduling the job through the task scheduler and not the at command. They each use different API's and stranger things have happened.

         8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        pkranthi

          Topic Starter


          Rookie

          Re: copying two text files using at command
          « Reply #21 on: February 06, 2008, 12:01:29 PM »
          As Suggested, I went to the task scheduler file->new->taskschedule. after clicking on the new task schedule nothing is happening(no response from the system). I do not know why.

          Thanks,
          kranthi

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: copying two text files using at command
          « Reply #22 on: February 06, 2008, 12:08:20 PM »
          I guess what is bothering me the most is that the window is not opening. You could check the event log and see if anything turns up.

          Also check the task manager while the scheduler indicates the job is running. Is there an entry for cmd.exe in both the applications and processes tab?

          It almost seems like the job gets lost in the system.

           8)
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          pkranthi

            Topic Starter


            Rookie

            Re: copying two text files using at command
            « Reply #23 on: February 06, 2008, 12:44:53 PM »
            ------You could check the event log and see if anything turns up.

            This what the ven log say when the taskscheduler says running.

            "At2.job" (sample.bat)
               Started 2/6/2008 2:39:00 PM.

            ------Also check the task manager while the scheduler indicates the job is running. Is there an entry for cmd.exe in both the applications and processes tab?

            Applications tab:

            C:|WINDOWS|system32\cmd.exe                Running

            Process tab:

            cmd.exe          system               
            cmd.exe          system
            cmd.exe          u08432

            If this doesnt work is there any other way to automate the concatination of the two files with out using any third party tools.

            Thanks,
            kranthi

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: copying two text files using at command
            « Reply #24 on: February 06, 2008, 02:06:14 PM »
            I'm all out of ideas. It doesn't get much simpler than the COPY statement. You might try VBScript or JScript which come installed on Windows machines.

            Good luck. 8)

            PS. I tested copying files over a network and using the at command with no problems. Probably something ridiculously simple. ???
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            pkranthi

              Topic Starter


              Rookie

              Re: copying two text files using at command
              « Reply #25 on: February 06, 2008, 06:07:37 PM »
              -------PS. I tested copying files over a network and using the at command with no problems. Probably something ridiculously simple.

              Could you please post it as it is what is in the batch file and what you typed in dos promt to schedule the batch file to run. May be I could figure it out from there. (Please provide the directory where you scheduled the batch file)

              Thanks,
              kranthi

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: copying two text files using at command
              « Reply #26 on: February 06, 2008, 06:37:33 PM »
              First I created 1.txt:

              echo aaaa>1.txt

              The I created 2.txt:

              echo bbbb>2.txt

              The I created sample.bat in the temp directory:

              net use m: \\STORAGE-72AD\NetHDD2
              copy m:\1.txt +m:\2.txt m:\1.txt


              Then I scheduled the job:

              at 3:57pm "c:\temp\sample.bat"

              After the job ran, I checked 1.txt:

              M:\>type 1.txt
              aaaa
              bbbb


              Hope this helps.  8)
              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              pkranthi

                Topic Starter


                Rookie

                Re: copying two text files using at command
                « Reply #27 on: February 06, 2008, 07:43:44 PM »
                ------net use m: \\STORAGE-72AD\NetHDD2

                i did not understand what this is?

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: copying two text files using at command
                « Reply #28 on: February 07, 2008, 05:24:45 AM »
                Quote
                net use m: \\STORAGE-72AD\NetHDD2

                Actually that is specific to my system but it turns out it's the solution. Back in post #18 I asked:

                Quote
                Not to be obvious, but do you have a connection to the J: drive?

                At first glance it's a throwaway question, and you probably do have a connection under your id. If you place a job on the scheduler through the GUI, the job credentials are your id. However, if you use the AT command it turns out the job credentials are SYSTEM, for which probably no such connection exists.

                Bottom line is your code needs to map the network drive; the easiest way is net use.

                I only stumbled on this because I rarely need my network drives; writing network connection logic only when needed.

                Let's hope this works.  8)

                PS. net use /? at a command prompt will explain how to use the command
                The true sign of intelligence is not knowledge but imagination.

                -- Albert Einstein

                pkranthi

                  Topic Starter


                  Rookie

                  Re: copying two text files using at command
                  « Reply #29 on: February 08, 2008, 02:05:39 PM »
                  I figured the same thing, when I was running the batch file it was running with my user name and did not have any problem to access the files on netwrok. But when I schedule the job the creator is becoming the system, so I went to the task scheduler and in advence tab I changed the user name of my schedule to mine and gave my system login passowrd and now the schedule works.

                  Thanks Sidewinder for all the help.
                  K