Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faking standard input on the Windows command line

I want to use Evernote's ENScript.exe to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standard input.

For my current workaround I use a .bat file to write the argument to a file, then call ENScript with the /s argument pointing to the file to read it in, but that forces the default title to the temporary file's filename (a behavior I do not want).

So my question is: Is there a way to "fake" standard input on the Windows command line so that I can use an argument (passed from another program) to generate the note text? The beginnings of the script would be something like

ENScript.exe createNote /i %1

with the standard input following.

like image 687
Ryan Avatar asked Apr 14 '13 01:04

Ryan


People also ask

What is insert mode in CMD?

Insert Mode is a mode within the Editor that allows any number of new lines to be inserted in an item. Insert Mode is invoked when you type the I command without any text, and is exited by pressing ENTER on an empty line.


1 Answers

You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.

The pipe symbol for Windows CMD is |

Your script could be as simple as:

@echo %~2|@ENScript.exe createNote /i %1

If your script is called MakeNote.bat, you would call it like

MakeNote "your title" "This is the text of your note"
like image 84
dbenham Avatar answered Oct 03 '22 15:10

dbenham