| 1. |
Solve : searching for a string in dos window output? |
|
Answer» Hello everybody, In my case i launch the application "A". When in the output i read "running" i want to launch application "B".Quote from: macdad- on September 09, 2009, 07:29:58 AM Thats what's its supposed to do: Code: [Select] @echo off appA.exe | findstr "running" > temp.tmp for /f %%a in (temp.tmp) do ( if '%%a'=='running' goto appB ) :appB This code will go to label :appB, whether or not the word 'running' is found, so what is the point of the IF test? Quote from: Salmon Trout on September 09, 2009, 07:40:09 AM Code: [Select] it is not supposed to do that it should go do label appb only if i see in the console output the "prograM is running" string. i would prefer to read to console because the output to teMp file, after a while, stops and i think it is redirect to another file. I've tried with the /g OPTION but i do not understand how to insert the "/" for the console. I tried everything with any result. Anyway if you have a link with a clear explanation of batch coMMands it would help a lot. Thanks byeQuote from: mrguzzi on September 09, 2009, 01:46:58 PM it is not supposed to do that Indeed. Quote from: Salmon Trout on September 09, 2009, 01:48:57 PM Indeed.so? any proposal?Quote from: mrguzzi on September 09, 2009, 02:13:08 PM so? any proposal? Quote In my case i launch the application "A". When in the output i read "running" i want to launch application "B". Let me make sure I have this right. You launch A and it produces screen output, which might, or might not, include the word "running"? Is that right? Or do you mean, it will produce the word "running" sooner or later, and you want to wait until that happens? Quote When the log file written by "B" contains the "running" string i launch application "C". You see, that word "when" is niggling away in my mind. Are you aiming to monitor the logfile while program B is running, and when you once again see the word "running" in it, then you launch program C? And please, why are you being all coy and calling the programs A, B and C? Why is it such a big secret what you are trying to do, what the programs are called, and what they do? How do you expect any serious help if you just give part of the needed information? The logic for batch files can be LIKE this: Code: [Select]If thing == true goto NotFalse goto IsFalse :NotFalse echo It was ture. goto AllDone :IsFalse echo Yes, it was not ture. :AllDone You use the goto to create code blocks. Quote from: Salmon Trout on September 09, 2009, 03:41:37 PM .. it will produce the word "running" sooner or later, and you want to wait until that happens? this is it Quote from: Salmon Trout on September 09, 2009, 03:41:37 PM You see, that word "when" is niggling away in my mind. Are you aiming to monitor the logfile while program B is running, and when you once again see the word "running" in it, then you launch program C?sorry for my bad english. I mean that as soon as i see in the logfile the phrase "program B is running" i want to launch the program C Quote from: Salmon Trout on September 09, 2009, 03:41:37 PM And please, why are you being all coy and calling the programs A, B and C? Why is it such a big secret what you are trying to do, what the programs are called, and what they do? How do you expect any serious help if you just give part of the needed information? No secrets at all :-) it's just for semplification. Anyway program A is Bea weblogic server, B is a server-side code running on bea weblogic and program C is a TESTING unit that runs on B. That's all Actually i'll try Geek solution. The only open point is how to use findstr on console without reading the temp file. Thanks a lot Byeok i went forward now my problem is here appA.bat | findstr "running" > temp.tmp until appA finishes (and it does not do it) the batch does not continue Actually appA = run server_admin I've tried all of these start run server_admin >temp.tmp run server_admin | findstr /c:"RUNNING mode" >temp.tmp call (run server_admin) | (findstr /c:"Server started in RUNNING mode")> temp.tmp don't know how to try So how can i launch a bat file (in my case run.bat), get it's output to a file and continuing searching in this file before run.bat finishes? like this: run server_admin >temp.tmp :wait_admin_console findstr /c:"RUNNING mode" temp.tmp if not ErrorLevel 1 goto continue goto wait_admin_console :continue ... thanks a lot bye |
|