Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using pipes.
#1
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 ?
Reply
#2
How about working through the _Clipboard?
b = b + ...
Reply
#3
If you're using Linux, tee is what you may be looking for. https://www.geeksforgeeks.org/tee-comman...x-example/
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#4
(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)
Reply
#5
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.
Reply
#6
(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.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#7
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.


Attached Files Image(s)
       

.7z   qbpe_tcp_example.7z (Size: 576.01 KB / Downloads: 19)
Reply
#8
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.


Attached Files
.zip   Pipecom-master.zip (Size: 3.29 KB / Downloads: 18)
Tread on those who tread on you

Reply




Users browsing this thread: 1 Guest(s)