•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 402,044 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,451 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 700 | Replies: 3
![]() |
Hi guys,
Basically what I want to do is run a series of commands in my batch file, and display stdout to screen as well as saving it in a file. So to set the context..
What I’d like to do is have the output of a single command directed to both. As a workaround I’ve got something which will output to a file, and then copy the contents of the file to console.
This isn’t ideal since I’d like for the user to see the activity in the console as the batch file is executing commands, rather than in a big batch at the end.
Cheers,
Anthony
Basically what I want to do is run a series of commands in my batch file, and display stdout to screen as well as saving it in a file. So to set the context..
::To output to helloworld.txt Echo hello world! > helloworld.txt ::To output to console Echo hello world! > CON
What I’d like to do is have the output of a single command directed to both. As a workaround I’ve got something which will output to a file, and then copy the contents of the file to console.
::Output to file then copy file contents to console echo Hello World! >test.txt copy test.txt con > nul
This isn’t ideal since I’d like for the user to see the activity in the console as the batch file is executing commands, rather than in a big batch at the end.
Cheers,
Anthony
Formerly known as Slade.
In unix-land, this would be a doddle.
http://www.rootr.net/man/man/tee/1
If you have cygwin installed, then you can just use the 'tee' provided in your cygwin bin directory.
Though if you search long enough, you might find a native Win32 implementation as well.
http://www.rootr.net/man/man/tee/1
If you have cygwin installed, then you can just use the 'tee' provided in your cygwin bin directory.
Though if you search long enough, you might find a native Win32 implementation as well.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Hi Salem,
Thanks for your reply. The problem is that it kind of has to be native to windows since these are scripts that will be run on other peoples machines who may not have cygwin. I'll keep digging around and see if I can figure this one out. Will keep you all posted.
Actually on this note (but on a tanget to the topic), I have another script which I use to generate C# code documentation using doxygen. If someone doesn't have doxygen clearly this script will not work. I figure one potential way around it though might be to package the doxygen exe with the scripts (I guess this would work for the tee suggestion as well) - but I'm not sure licensing would really permit that. I haven't looked into it myself in depth yet, but would anybody know off hand if the GNU General Public License allows for this?
To me that sounds like a yes, but I could be mistaken.
Cheers,
Anthony
Thanks for your reply. The problem is that it kind of has to be native to windows since these are scripts that will be run on other peoples machines who may not have cygwin. I'll keep digging around and see if I can figure this one out. Will keep you all posted.
Actually on this note (but on a tanget to the topic), I have another script which I use to generate C# code documentation using doxygen. If someone doesn't have doxygen clearly this script will not work. I figure one potential way around it though might be to package the doxygen exe with the scripts (I guess this would work for the tee suggestion as well) - but I'm not sure licensing would really permit that. I haven't looked into it myself in depth yet, but would anybody know off hand if the GNU General Public License allows for this?
•
•
•
•
Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
To me that sounds like a yes, but I could be mistaken.
Cheers,
Anthony
Formerly known as Slade.
•
•
Join Date: Oct 2007
Posts: 267
Reputation:
Rep Power: 1
Solved Threads: 26
Hey There,
Here's a link to a win32 tee emulator:
http://www.csc.calpoly.edu/~bfriesen.../console.shtml
Otherwise, if you can somehow manage to do this with robocopy, it's the only dos command I know that has a /TEE option
Best of luck,
Mike
Here's a link to a win32 tee emulator:
http://www.csc.calpoly.edu/~bfriesen.../console.shtml
Otherwise, if you can somehow manage to do this with robocopy, it's the only dos command I know that has a /TEE option
Best of luck,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: .bat need help with this simple command
- Next Thread: Colors in bash



Linear Mode