Reading command line output from another batch script?
Moderator: DosItHelp
-
- Posts: 5
- Joined: 20 Aug 2012 11:20
Reading command line output from another batch script?
Hey guys,
I am relatively new to DOS and Batch Scripting but I am attempting to make a Batch script file that does a rough time calculation based on a time (I.E. 08:24) from a third party program.
The way it works is I first execute a third party program called "CCExtractor". It begins writing progress to the stdErr output. I then want to execute my batch script to skim the command output from the CCExtractor process. I've seen a lot of people write the output to some type of text file but I do not think this is feasible in my case because I would continually have to reopen the file in my batch script and not sure if that would work since the CCExtractor program would continually be writing to it.
I have my batch script working by reading a txt file of the output CCExtractor gives but I am not sure how to have this run in conjunction with the CCExtractor ouput!
Any Ideas??
I am relatively new to DOS and Batch Scripting but I am attempting to make a Batch script file that does a rough time calculation based on a time (I.E. 08:24) from a third party program.
The way it works is I first execute a third party program called "CCExtractor". It begins writing progress to the stdErr output. I then want to execute my batch script to skim the command output from the CCExtractor process. I've seen a lot of people write the output to some type of text file but I do not think this is feasible in my case because I would continually have to reopen the file in my batch script and not sure if that would work since the CCExtractor program would continually be writing to it.
I have my batch script working by reading a txt file of the output CCExtractor gives but I am not sure how to have this run in conjunction with the CCExtractor ouput!
Any Ideas??
Re: Reading command line output from another batch script?
'
Place your command/program inside a for loop
Notice the smileys 
Place your command/program inside a for loop
Code: Select all
@echo off
for /f "delims=" %%? in (
'for /?'
) do echo.%%?
pause
exit

-
- Posts: 5
- Joined: 20 Aug 2012 11:20
Re: Reading command line output from another batch script?
Thanks for the reply!
That worked. Is there a way to get the 'stdOut' output similar to the 'stdErr?'
This doesn't seem to work!
That worked. Is there a way to get the 'stdOut' output similar to the 'stdErr?'
Code: Select all
FOR /F "tokens=*" %%i in ('"ccextractorwin.exe --gui_mode_reports -out=srt -trim GP066367.mpg"') do (
echo %%i
)
This doesn't seem to work!

Re: Reading command line output from another batch script?
'
try
But first check if it works at all
try
Code: Select all
FOR /F "tokens=*" %%i in ('"ccextractorwin.exe" --gui_mode_reports -out^=srt -trim GP066367.mpg') do (
echo %%i
)
Code: Select all
"ccextractorwin.exe" --gui_mode_reports -out=srt -trim GP066367.mpg
-
- Posts: 5
- Joined: 20 Aug 2012 11:20
Re: Reading command line output from another batch script?
Hey I tried this:
It seems to work but for whatever reason it seems to think: out=srt is an input file.
It is trying to process "srt" as its own file. Is there a way to correctly supply the arguments?
Code: Select all
FOR /F "tokens=*" %%i in ('"ccextractorwin.exe" --gui_mode_reports -trim GP066367.mpg -out=srt') do (
echo sadsd %%i
)
It seems to work but for whatever reason it seems to think: out=srt is an input file.
It is trying to process "srt" as its own file. Is there a way to correctly supply the arguments?
Re: Reading command line output from another batch script?
Does the program expect the last part of the command to be the input file?
IE: try the command from the prompt:
ccextractorwin.exe --gui_mode_reports -trim GP066367.mpg -out=srt
IE: try the command from the prompt:
ccextractorwin.exe --gui_mode_reports -trim GP066367.mpg -out=srt
-
- Posts: 5
- Joined: 20 Aug 2012 11:20
Re: Reading command line output from another batch script?
This command does indeed work in the command prompt.
It appears the = sign is causing problems.
Code: Select all
ccextractorwin.exe --gui_mode_reports -trim GP05312.mpg -out=srt
It appears the = sign is causing problems.
Re: Reading command line output from another batch script?
script-newbie wrote:This command does indeed work in the command prompt.Code: Select all
ccextractorwin.exe --gui_mode_reports -trim GP05312.mpg -out=srt
It appears the = sign is causing problems.
Shouldn't it be -o filename
Re: Reading command line output from another batch script?
script-newbie wrote:This command does indeed work in the command prompt.Code: Select all
ccextractorwin.exe --gui_mode_reports -trim GP05312.mpg -out=srt
It appears the = sign is causing problems.
Try escaping the equals sign like this: ^=
or use "-out=srt" with the double quotes, if the program supports them.
-
- Posts: 5
- Joined: 20 Aug 2012 11:20
Re: Reading command line output from another batch script?
I really appreciate the help!
But I am not sure if this solution will work.
When this executes it outputs the CCExtractor output but I am unable to access it. In theory it should have "TEST" in front of each CCExtractor stdout output on the Command Window screen but this doesn't work.
It does print out my TEST output but not until the CCExtractor output is finished.
But I am not sure if this solution will work.
Code: Select all
FOR /F "tokens=*" %%i in ('"ccextractorwin.exe" --gui_mode_reports -out^=srt -trim GP066367.mpg -stdout -o GP066367.srt') do (
echo TEST %%i
)
When this executes it outputs the CCExtractor output but I am unable to access it. In theory it should have "TEST" in front of each CCExtractor stdout output on the Command Window screen but this doesn't work.
It does print out my TEST output but not until the CCExtractor output is finished.
Re: Reading command line output from another batch script?
If it doesn't work then this is unrelated to the batch, which is syntactically correct ( all special characters are either quoted or escaped ). This doesn't mean you won't run into problems because of the way you chose to retrieve and handle the output.script-newbie wrote:But I am not sure if this solution will work.Code: Select all
FOR /F "tokens=*" %%i in ('"ccextractorwin.exe" --gui_mode_reports -out^=srt -trim GP066367.mpg -stdout -o GP066367.srt') do (
echo TEST %%i
)
Sorry, das habe ich nicht verstehen was meinst du ?script-newbie wrote:When this executes it outputs the CCExtractor output but I am unable to access it.
unless your version of cmd.EXE is broken, it works for everybody else.script-newbie wrote:In theory it should have "TEST" in front of each CCExtractor stdout output on the Command Window screen but this doesn't work.
Code: Select all
>for /f "tokens=1-2" %a in ( 'echo.line1A line1B ^&echo.line2A' ) do echo.TEST %a &echo.TEST %b
>echo.TEST line1A & echo.TEST line1B
TEST line1A
TEST line1B
>echo.TEST line2A & echo.TEST
TEST line2A
TEST
>
Yes, that is how 'for /?' works.script-newbie wrote:It does print out my TEST output but not until the CCExtractor output is finished.