Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Collecting stdout into DOS variable

Posted on 2006-07-01
4
Medium Priority
?
1,430 Views
Last Modified: 2012-08-13
I am new to DOS programming - I have written a batch script to execute a program and write stdout to a file.
I am not gettign the syntax to collect it into a variable instead of a file.Is there a way?
pardon my ignorance.
I am using the following syntax now:
set STDERR=stderr.txt
REM time the job by writing timestamps to a file
echo Begin at: 1>%STDOUT% 2>%STDERR%
time /T 1>>%STDOUT% 2>>%STDERR%
date /T 1>>%STDOUT% 2>>%STDERR%

REM run the j
IEClient.exe %* 1>>%STDOUT% 2>>%STDERR%

Can stdout be collected into a variable directly.
or do i have to repoen the output file into a variable?
0
Comment
Question by:ranadhir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 200 total points
ID: 17037059
Short answer anyway is no.  You are redirecting to the contents of the variable, i.e. a file called blank.  You can redirect to a file then use a for command to read the first or a specific line of the file into a variable.  Ask if that is what you want (here or in MS-DOS)... more points might help too.

BTW From W2K up you can use

set stdout=stdout.txt
set stderr=stderr.txt
echo Begin at %time% %date% 1> %stdout% 2> %stderr%
ieclient %* 1>> %stdout% 2>> %stderr%

for /f %I in ('%stdout%') do set test=%I&gotocontinue
:continue
echo The variable TEST is set to %test%

Not sure what you are actually trying to do though.  Please post again ... and more points... for more info.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question