[SOLVED] Accepting Input via PIPE but not via Keyboard lazarus / 13-General ---------------------------------------------------------------------- ASBzone · 2018-07-18 14:47 Greetings, I am developing a Windows console app that accepts parameters at the command-line, and I have added the following to enable it to grab information via PIPE as well.    (e.g. ECHO Some Stuff Here | myapp.exe ) The pipe part works fine using the following: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i while (not EOF) do begin  ReadLn(InputVar);  WriteLn('You entered: ', InputVar);end;  However, if I run the command without having piped input, it waits for keyboard input.   What are my options for forcing STDIN to ignore the keyboard, so that it only tries to execute the ReadLn command if, in fact, data has been piped to the app? I have seen threads such as below, which were helpful to me for getting the piping working at all.  But they don't address the other part of my issue.  https://forum.lazarus.freepascal.org/index.php?topic=16274.0 https://forum.lazarus.freepascal.org/index.php?topic=24663.0 Thanks ---------------------------------------------------------------------- ASerge · 2018-07-18 15:15 Quote from: ASBzone on July 18, 2018, 04:47:37 pmI am developing a Windows console app... What are my options for forcing STDIN to ignore the keyboard, so that it only tries to execute the ReadLn command if, in fact, data has been piped to the app? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$MODE OBJFPC}{$APPTYPE CONSOLE} uses Windows; function IsStdHandleRedirected(Handle: THandle): Boolean;var  Unused: DWORD;begin  Result := (GetFileType(Handle) <> FILE_TYPE_CHAR) or not GetConsoleMode(Handle, @Unused);end; begin  if IsStdHandleRedirected(StdInputHandle) then    Writeln('In pipe')  else    Writeln('OK')end. ---------------------------------------------------------------------- ASBzone · 2018-07-18 17:41 Awesome and exquisite. Thanks, ASerge.  Works perfectly... ---------------------------------------------------------------------- ASerge · 2018-07-18 21:51 Advice for the future. If you later want to read the console output, even if you are redirected, you can do so by opening a file with a special name 'CONIN$'. ---------------------------------------------------------------------- ASBzone · 2018-07-18 23:41 Quote from: ASerge on July 18, 2018, 11:51:48 pmAdvice for the future. If you later want to read the console output, even if you are redirected, you can do so by opening a file with a special name 'CONIN$'. Advice accepted and stashed away safely. Thanks again.