[Gambas-user] Help with SHELL and EXEC
Kari Laine
klaine8 at ...626...
Sun Oct 12 16:00:36 CEST 2008
On Sun, Oct 12, 2008 at 4:31 PM, Benoit Minisini <
gambas at ...1...> wrote:
> On dimanche 12 octobre 2008, Doriano Blengino wrote:
> >
> > Tell me what your tests say to you - this is very interesting because I
> > did not try if that book was true or not.
> >
>
> Strange behaviours.
>
> If I replace INPUT OUTPUT by READ WRITE, the process does not write to its
> standard output anymore.
>
> But if I replace the "tr" program by "cat", then READ WRITE works as
> expected.
>
> So there is something different in "tr" that prevents him to work with the
> READ WRITE options.
>
> Moreover, sometimes the first write to the "tr" process fails (with a bad
> file
> descriptor error message).
>
> All that needs some investigation...
>
> To test whether either WRITE or OUTPUT works without READ or INPUT I made a
little filter which stores it input to output file.
Here is the filter
-------
#include <stdio.h>
int main()
{
int character;
int lask;
FILE *nHandle;
printf("program started\n");
nHandle=fopen("/home/kari/output.txt","w");
character = getc(stdin);
while(character != EOF)
{
//printf("%d",character);
fputc(character,nHandle);
character = getc(stdin);
}
close(nHandle);
}
-------------------------
Then I start process like this
nProcess = EXEC ["/home/kari/dblpipe/a.out"] FOR WRITE
I also tried OUTPUT instead of WRITE
Then I have a button with code
PUBLIC SUB Button1_Click()
WRITE #nProcess, "heippa" & Chr(10)
END
I also tried PRINT instead of WRITE and with or without Chr(10).
I can't get it working - nothing ends up in output.txt file. It could be a
question of buffering somewhere but I don't know.
Hopefully this process handling thing can be fixed (or not if it is a
feature of Linux) because this would be great way to integrate to other
programs.
Every programming language has concept of stdin and stdout as far as I know.
Thank you for all the help so far.
Best Regards
Kari Laine
More information about the User
mailing list