Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

how to redirect the output to a function parameter

I am trying to get an output stream in batch script in to a function parameter that can be passed ..is this even possible ?
0
shadow2007
Asked:
shadow2007
  • 3
  • 2
1 Solution
 
knightEknightCommented:
Please provide more details - what exactly are you trying to do?  What is the expected input and output?
0
 
shadow2007Author Commented:
echo create type nsr client; name: test; | nsradmin -i-


:log
echo %*
echo %*>>log.txt
exit /b

I want to be able to send the out put from nsradmin to call :log so it displays on the screen and send it to log file

0
 
Bill PrewCommented:
Does nsradmin produce a single line of output, or multi line?

If multi, do you want to call :log once for each line, or only one time for the whole group of lines?

~bp
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Bill PrewCommented:
Give this a try to see if it gets you close:

for /F "tokens=*" %%A in ('echo create type nsr client; name: test; ^| nsradmin -i-') do (
  call :log %%A
)
exit /b

:log
  echo %*
  echo %*>>log.txt
  exit /b

Open in new window

~bp
0
 
shadow2007Author Commented:
bill
both sometimes one sometimes multi
0
 
Bill PrewCommented:
Okay, give the approach I showed a try and let me know how that goes.

~bp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now