Process: write to its stdin and capture its stdout
Posted
#1
(In Topic #1164)
Trainee
I have this problem.
I need to Exec a command, writing to its standard input, then capturing what it writes to stdout.
I've been bouncing back and forth in the Gambas documentation wiki, without much success.
Code (gambas)
There is some code here in the wiki https://gambaswiki.org/wiki/lang/open which seems to align with the notion of "read events" I found here and there, which involves the definition of a sub called NAMEOFFILE_Read that is seemingly associated in a magic way to the file with the same name. But it looks like I cannot define a sub inside a sub, so I'm at a loss.
Any help is greatly appreciated.
Posted
Regular

…ma sei Veneto ?Carotino said
Code (gambas)
Print ostrega
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Regular

Some of my desperate studies in this regard:
Intercettare i dati inviati allo standard output da un programma C - Gambas-it.org - Wikipedia
Intercettare il risultato restituito ad intervalli temporali di un comando bash - Gambas-it.org - Wikipedia
Intercettare la stringa di caratteri immessi dall'utente nella console o Terminale - Gambas-it.org - Wikipedia
Intercettare quanto viene scritto manualmente nella console o in un Terminale - Gambas-it.org - Wikipedia
https://www.gambas-it.org/wiki/index.php/Scrivere_nella_console_(standard_output)_di_Gambas
Scrivere nello Standard Input di un Terminale con un programma Gambas 'a riga di comando' - Gambas-it.org - Wikipedia
Alsa e Gambas: Ricezione dei dati Midi con un programma esterno di supporto - Gambas-it.org - Wikipedia
In general, for Reading and Writing with a Process:
Lettura dati da un Processo e scrittura dati in un Processo mediante Process - Gambas-it.org - Wikipedia
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Trainee
vuott said
…ma sei Veneto ?Carotino said
Code (gambas)
Print ostrega
LOL hai ragione, in realtà sono bergamasco, di solito uso nomi sensati per le variabili ma per l'appunto ero arrivato all'ostrega
Posted
Trainee
By the way I understood what I previously referred to as "magical", that is Event names.
In the end I think I'll end up to use something to the likes of
or, which I thinks should be better in the long run, I'll use temporary files in /dev/shm to pass data around.
It still baffles me that such a trivial task is so overly convoluted
Thanks very much
Posted
Regular

For passing data from one program to another, you can also see these pages:Carotino said
I'll use temporary files in /dev/shm to pass data around.
Guide della comunità - Gambas-it.org - Wikipedia
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

Carotino said
Well, congrats for your research!
By the way I understood what I previously referred to as "magical", that is Event names.
In the end I think I'll end up to use something to the likes of
or, which I thinks should be better in the long run, I'll use temporary files in /dev/shm to pass data around.
It still baffles me that such a trivial task is so overly convoluted
Thanks very much
Here is a simple method to use piping with your program..
Code (gambas)
- $sPipedString = GetStdio()
- ' If user typed something like echo "this text" | myProgram.gambas in a terminal
- ' now $sPipedString will be "this text"
- Return SourceBuffer
1 guest and 0 members have just viewed this.


