https://stackoverflow.com/questions/3252957/how-to-execute-shell-script-from-latex
Is there any way to execute a program and have it directly insert it's stdout in to the tex stream without having to output to a temp file and then input that file? [I've tried some of the code in the link but it does not work, specifically the 2019 update code).
If not, is there an easy way to generate a random file name that won't collide and then input it and delete it? Ideally though this is not the method I'd like.
I can use the write18 method and input but it is not desirable.
\GetShellOutputdefined in the answer does exactly what you want. It can easily be modified to take a parameter that defines what is to be executed. – Peter Grill Sep 26 '19 at 00:33\GetShellOutputmacro that is linked in my earlier comment. The two filesA.txtandB.txtare not temp files -- they are there only because the command I want to execute is intended to extract info from a file, and those two are the test files. – Peter Grill Sep 26 '19 at 15:58l.30 \GetShellOutput Please type another input file name:. e.g., I simply modified the code:\@@input|"head -1 \FBFileNameWithPath | grep '^XY:'" }}%to\@@input|"dir" }}%. I've tried with other things such as the exe I want to run with the full path and it gives the same error. So maybe it doesn't use a temp file but I cannot get it to work. – Sep 26 '19 at 16:35\@@input|"pwd" }on MacOS and seems to work fine. Are you using the-shell-escapeoption topdflatex? If that is not the problem, I suggest you post a new question and include a compile MWE including\documentclassand the appropriate packages that reproduces the problem that you are having. – Peter Grill Sep 26 '19 at 18:35\makeatletter \@@input"dir" \makeatotherit fails with the same error. (with or without the |) – Sep 26 '19 at 18:45Text line contains an invalid characterso it at least does something different. Using|fails though. – Sep 26 '19 at 18:50|was breaking the code. Now I get errors likeIllegal parameter number in definition of \TempResultandText line contains an invalid character. – Sep 26 '19 at 18:53\input. Maybe\@@input|".."is suppose to execute the command but in my case it says it can't find the file|.... This is on windows. Maybe it works on linux correctly but not so much on windows. I will just use a temp file, at least it works. – Sep 26 '19 at 19:01