Saved Bookmarks
| 1. |
Solve : Input\Output Batch File? |
|
Answer» Hi,
To write to a file you can use '>>' or '>' Code: [Select]echo Hello, World! >>file.txt ping 127.0.0.1 >>output.txt echo %1 >>input.txt for /f %%a in (file.txt) do (echo %%a >>input.txt) [code] We will need a little more information as to the problem to better provide help.Following code will take input from same file and paste output in same file. FOR /F "usebackq tokens=*" %%a in ("log.txt") do echo %%a >> "log.txt"Basically i'm trying to individually add a large amount of users to 64 servers. so what i meant by input and ouput is that it shows you the command you running and the response it gives. If someone already has access to a server it STATES dsadd failed: already a member. Unfortunately some people used '0' instead of 'o' when inputting server names, so when i try to add them to that server i just get dsadd failed. Because of the large amount of commands being used, i cant see which command has failed Does that make sense?(same reply as elsewhere) You are running a batch file with the 'dsadd' tool in I presume. As long as it doesn't require keyboard input launch it like this: Code: [Select]batch.bat >dsadd-log.txt and then you can filter the log file with a command looking for errors and examine dsadd-error.txt Code: [Select]find "already a member" <dsadd-log.txt >dsadd-error.txtsorry im not using dsadd. Im using dsmod group -addmbr I dont understand the second part of what you said iv created a log file which is showing the comman added but its not showing the error I'm sorry for any confusion. I'm fine with getting the output from the batch file into a log file (> log.txt). My problem is that there are a lot of lines in the batch and the errors from dsmod do not show any detail about the issue. I'd like to show the commands from the batch file in addition to the output. My batch file looks like: command > log.txt command1 >> log.txt I know that I could do echo command > log.txt command >> log.txt echo command1 >> log.txt command1 >> log.txt but I thought there must be a way to tell command prompt to log the commands, as well as the output, to a file.... If I can see the command above the error in the log file, I'll know exactly what didn't work.You could try this: If the batch file starts @echo off either comment that line out like this REM @echo off or change it to this @echo on or delete it altogether Thanks for the advice. Won't this just output the commands to the screen though? I want to echo the commands to a file.If you are redirecting the whole batch output to a file (as in foxidrive's reply no. 7 above) like this... blablabla.bat > somefile.xyz ...then everything that would normally* go to the screen** will end up in the file. Try it. Did you say the error messages are ending up in the output file? * i.e. the stdout stream ** except error messages SENT to the stderr stream; some programs do this. If that is relevant to this situation it will become apparent I imagine. yeah i've tried that and it does exactly what you say. What im trying to do is get the errors that come with them so i know which one has failed. to an extent i've got the errors to send to a different file but its only showing one error instead of 4. Is this overwriting itself?I'm pretty sure it will over write itself if you use only 1 > instead of >>. But it's equally as likely I'm wrong. Quote from: AndrewUsh on February 05, 2013, 05:11:26 AM to an extent i've got the errors to send to a different file but its only showing one error instead of 4. Is this overwriting itself? need to see your code. Otherwise this is guesswork. |
|