Skip to content

redirect_bin_output

Joseph Harkleroad edited this page Mar 16, 2018 · 4 revisions

redirect_bin_output

NAME

redirect_bin_output.exe - redirect the output of a binary into files

SYNOPSIS

redirect_bin_output.exe <binary name> <arg1> <arg2> <argN>

DESCRIPTION

redirect_bin_output.exe will execute a binary with its given arguments and redirect that executable's stdout and stderr to dynamically named log files.

redirect_bin_output will provide the user feedback on usage and error conditions during it's execution. This output is minimal. All output for the executable it is "wrapping" will be wrapped into log files named after the binary itself.

Two log files will be created during the execution of a binary: "output" and "errors". Depending the executable's output, any of the files may be empty. The log filenames are created with three main criteria: date/time stamp, binary name, type of output. The log filenames will be prepended with a date/time stamp. The name of the executable will also be included in the log file names. Finally, stdout will be redirected into the "output" file and stderr will be redirected into the "errors" file. The filenames will follow this general format: YYYYMMDD-HHMMSS-wrapped_bin-output.txt -or- YYYYMMDD-HHMMSS-wrapped_bin-errors.txt

If you experience errors and wish to see more ERROR output, uncomment the "HARKLE_DEBUG" MACRO in "Latissimus_Dorsi/3-Internals/Harklerror.h", build with Make, and run it again.

COMPILATION

  1. git clone https://github.com/hark130/Latissimus_Dorsi.git
  2. cd Latissimus_Dorsi
  3. make redirect_bin_output

EXAMPLE

$ ./redirect_bin_output.exe /bin/ls -l ~/Documents

/// ADD ACTUAL OUTPUT LATER ///

NOTES

  • You may need to include a relative or absolute path to the binary being "wrapped"
  • No support for sudo as of yet
  • Log files are created with permissions 664

BUGS

  • CLAMPS believes that there is a race condition to edit the output files if the same process is at the same exact time. In the situation that both of these processes want to write to the same filename, they'll mix up output within the file itself. Solution? File lock or include the PID in the filename.
Clone this wiki locally