QB64 Phoenix Edition
Using pipes. - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Using pipes. (/showthread.php?tid=3083)



Using pipes. - ahenry3068 - 09-28-2024

When using the Shell command I can redirect STDOUT with the standard command line syntax.    I have used the technique to use write files then open them in my code.

However      Is there a way to have the program output to a pipe and have my program read from the pipe without using an intermediate file ?


RE: Using pipes. - bplus - 09-28-2024

How about working through the _Clipboard?


RE: Using pipes. - grymmjack - 09-28-2024

If you're using Linux, tee is what you may be looking for. https://www.geeksforgeeks.org/tee-command-linux-example/


RE: Using pipes. - ahenry3068 - 09-29-2024

(09-28-2024, 02:49 PM)bplus Wrote: How about working through the _Clipboard?

    That might work sometimes but I really want to do something like this   

Basic.ish psuedo code:

   shell _dontwait "someprogramIneed | mypipe"

   open "mypipe" for input as #1

   do
      LINE INPUT #1,  MyVar$
      Parse_Var_and_TakeAction MyVar$
  loop until EOF(mypipe)


RE: Using pipes. - Gomez Addams - 09-29-2024

I just joined up here and I saw your post. I just had the exact same need. Thought of redirects and pipes, but I resolved the problem using a tcp connection between the two programs. I despaired of the built in tcp functions and unsafe warnings in qbpe docs, and just rolled my own little client / server in C to do the job. The qbpe / C code interface is really powerful once you figure out how to pass data from/to it. This was only made difficult because I don't actually know what I'm doing. I will put  together a simple example for you and post it out here later if you are interested.


RE: Using pipes. - TerryRitchie - 09-29-2024

(09-29-2024, 01:58 PM)Gomez Addams Wrote: I just joined up here and I saw your post. I just had the exact same need. Thought of redirects and pipes, but I resolved the problem using a tcp connection between the two programs. I despaired of the built in tcp functions and unsafe warnings in qbpe docs, and just rolled my own little client / server in C to do the job. The qbpe / C code interface is really powerful once you figure out how to pass data from/to it. This was only made difficult because I don't actually know what I'm doing. I will put  together a simple example for you and post it out here later if you are interested.
First, Welcome the the forum!

Yes, I would very much like to see this. Thank you for sharing.


RE: Using pipes. - Gomez Addams - 09-29-2024

I attempted an upload of the code... see if this is of any use.
Please recompile for your env as I am running Debian SID which means my  
compilations may contain updated libraries others dont have yet.


RE: Using pipes. - SpriggsySpriggs - 10-01-2024

You can do STDOUT like you were asking for with pipecom. In Linux/Mac, stdout can be captured without a file. On Windows, stdout and stderr can both be captured without a file.
Pipecom is a utility I wrote for myself because I was sick of using files to capture shell commands. Files are the worst way to grab commands.