How can I run FIO for windows and redirect output to file and console simultaneously - console-redirect

I’m running FIO 2.1.8 (Windows 2012 R2) and I am trying to figure out how I can use a bat file with FIO and the –output= command, but also display the output to the console screen at the same time.
I want to be able to monitor the screen in real time but also need a log so I can parse for errors and metrics after the workload is done. The problem is it seems there is no way to do both.
If I include the output argument then all screen output is suppressed, and if I try to do any other type of redirection then the console never updates.
Does anyone know how to achieve this with FIO in Windows?
I've tried using
TEE (via Gow)
Standard dos redirection (eg &>1 )
Wrapping the bat file in a powershell script using START-TRANSCRIPT
In all cases this does not work.
"C:\Program Files\fio\fio.exe" --name=warmup --readwrite=randrw --rwmixread=70 --bs=64k --ba=64k --filename=E\:\FIO_
datafile.dat --size=32m --ioengine=windowsaio --runtime=900 --time_based --iodepth=4 --numjobs=32 --eta=always
Thanks...

PowerShell's Tee-Object worked for me:
& ./fio --eta=always --ioengine=null --thread --time_based --runtime=10s --size=1M --name=go | Tee-Object fioout.txt
(An aside: due to the way Windows works you don't exactly have pseudo-ttys so it's often hard for other programs to pretend to be terminals in a way the originating program won't detect as being a redirection to a file)

Related

Is it possible to spool to a file everything is typed from a windows terminal and its output?

I'm wondering whether is possible or not to spool to a file everything is typed from a Windows CMD terminal in order to record my work activity. I need to spool to the same file even what is performed from other interactive command line tools invoked from the terminal like Oracle SQL*Plus or any progamming language REPL like tool.
The goal is mainly to save some investigation activities made on a server for troubleshooting performance issues, so I can review all the metrics collected for each step after the issue is eventually disappeared.
Even if not useful at the moment, it would be nice to know how to do the same on both Unix/Linux and Mac OS.
You could start a PowerShell session and use:
Start-Transcript -Path $Env:USERPROFILE/mylog.txt
& "$Env:ComSpec" /K
REM enter commands and run batch files...
EXIT
Stop-Transcript
Get-Content -Path "$Env:USERPROFILE/mylog.txt"
The commands will not be in the mylog.txt file until after you exit the cmd.exe shell. I have no idea if it will work in the same way on Linux or Mac. I have not thought about it much.
If you need to record multiple shell sessions, they will probably need to write to different log files.

Powershell Script converted to EXE via Win-PS2EXE can be run manually but errors out when run as a scheduled task

The application moves files from one directory to another, runs an exe, and then moves files from one directory to another.
When I run the application manually it works as expected.
However, when trying to run it as a scheduled task I get the following error: 3762504530
I did some researching and it appears it may have to do with the application trying to run interactively even when there is no user actually logged in.
I have tried to suppress outputs but that didn't seem to have any effect.
Without seeing the code i guess u use console output or similar...
If so change write-host to write-output or alias "echo" pipe it to log file if u want...
Also be sure that your script run "non interactive" (no prompts etc.)
Unchecking compile a graphic windows program (parameter -noConsole), remedied the error.

How to work around ebook-convert.exe (in calibre portable) halting batch file execution?

I use ebook-convert.exe from a batch file, and on one of my machines (old Windows vista laptop), any calls ebook-convert.exe prevent further commands in a batch file from running (in that .bat file, or in that cmd shell instance for instance). The conversion to .mobi actually succeeds, prints no errors even in -v -v full verbose mode. I tried versions 1.20.0 and 0.9.6 of calibre portable. It seems to be related to the executable itself, and not to the specific conversion job (just running it with -h flag has same effect). I tried running cmd in administrator mode, wrapping it with 'call' command, nothing helps. Assuming the calibre issue is a black hole that can't be solved, is there a DOS trick I could possibly try to keep batch commands running no matter what odd thing happens with ebook-convert.exe on that machine?
Using call in a batch file should work on normal console programs but it is possible for programs to "escape" if they really want to.
Using Start instead might work but it does not wait by default and its syntax is not sane:
Start /B /WAIT c:\path\without\spaces.exe optionalParameter
or
Start "" /B /WAIT "c:\path\w i t h\spaces.exe" optionalParameter
Remove /B to run the application in a new console.
Another option is to call ping localhost and For (to get the file size with %%~zA) in a loop until the size of the destination file stops increasing. This is a bit of a hack and might not work, it depends on how the converter opens the file and how often it flushes the writes.

Re-directing standard error to console and file [duplicate]

This question already has answers here:
Displaying Windows command prompt output and redirecting it to a file
(32 answers)
Closed 8 years ago.
I am trying to redirect both the standard out and standard error in a Windows batch file to the same file.
However I would like the standard error and user input prompts to be displayed in the console as well.
I tried the following:
Process_SVN_Repos.bat > Process_SVN_Repos.log 2>&1
However this causes the STD ERROR to go to
the file (which I want), but does not show up in console and hence I can not input any user required inputs because I don't see any user prompt.
So basically I am trying to:
Redirect all std out to a file.
Redirect all STD ERROR to the same file.
Also show the same STD ERROR on the console.
See the user prompt the application needs in the console and be able to input the user prompt.
You need a tee command for Windows. Here are few options:
Rob van der woude pure batch solution / ....
Dave Benham's jscript/bat hybrid
Tee by Microsoft - it's part of Unix services for Windows (after installation it's available in the BIN folder and has no exe extension) - For XP/Windows Server 2003 for Windows Vista, Windows 7, Windows 8, Windows Server 2008, and Windows Server 2012.
Command line co uk
UnixUtls
Windows doesn't have a tee command, so you can't. As Windows includes Unix you could use one of those shells. I don't know if it has tee, but it has 350 utilities.
If you are using a Unix environment then you can easily use the tee command. But since you are on Windows, it doesn't support you directly. But there are alternatives that you can use.
I have used Wintee for a similar task like yours. I suggest you use that small utility called wtee.exe. If that can't help your task there are other alternatives as well.

How to capture and display output from a task via Windows CMD

I've got a PHP script which I'm running from a command line (windows) that performs a variety of tasks, and the only output it gives is via 'print' statements which output direct to screen.
What I want to do is capture this to a log file as well.
I know I can do:
php-cli script.php > log.txt
But the problem with this approach is that all the output is written to the log file, but I can't see how things are running in the mean time (so I can stop the process if anything dodgy is happening).
Just to pre-empt other possible questions, I can't change all the print's to a log statement as there are far too many of them and I'd rather not change anything in the code lest I be blamed for something going fubar. Plus there's the lack of time aspect as well. I also have to run this on a windows machine.
Thanks in advance :)
Edit: Thanks for the answers guys, in the end I went with the browser method because that was the easiest and quickest to set up, although I am convinced there is an actual answer to this problem somewhere.
You can create a powershell script that runs the command, reads the data from the command's STDOUT then outputs the output to both the log file and the terminal for you to watch. You can use the commands Write-Output and Write-Host.
Microsoft's site: http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/tee-object.mspx
Another option would be use find a tee program that will read input and divert it to two different outputs. I believe I have seen these for windows but I don't think they are standard.
Wikipedia: http://en.wikipedia.org/wiki/Tee_(command)
I have always opened the log file up in my web browser. This allows me to refresh it easily and does not interrupt any writing to the file that windows does. It isn't particularly elegant but it does work!
You want the "tee" command for Windows. See http://en.wikipedia.org/wiki/Tee_(command)
Powershell includes a tee command, and there are also numerous versions of tee for Windows available, for instance:
http://unxutils.sourceforge.net/
http://www.chipstips.com/?p=129
Also can be implemented in VBScript if you prefer.
EDIT: Just occurred to me I should also mention the tail command: http://en.wikipedia.org/wiki/Tail_(Unix). Tail allows you to read the last N lines of a file, and also includes a "file monitor" mode that just continually displays the end of the file in real-time. This is perfect for log file monitoring since it allows you to watch the log in real-time without interfering with the process that's writing to the log. There are several implementations of tail for Windows, both command line and GUI based. Microsoft's Services For UNIX packages (or whatever they're calling it now) also include a version of tail. Some examples:
mTail
Tail for Win32
WinTail
MakeLogic Tail
Some of these go far beyond just displaying the file in real-time as it updates and can send email alerts and colorize string matches, monitor multiple files at once, etc.
Slow:
for /f "delims=" %a in ('php-cli script.php') do #echo %a&echo %a>>log.txt
or in a batch file:
for /f "delims=" %%a in ('php-cli script.php') do #echo %%a&echo %%a>>log.txt

Resources