Solved

Collecting stdout into DOS variable

Posted on 2006-07-01
4
1,414 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
4 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 50 total points
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now