[Gambas-user] reopen standard input
Mike Keehan
Mike at ...680...
Fri May 30 17:00:22 CEST 2008
Robin Thompson wrote:
> Hi,
>
> I'm trouble with a console program i'm writing. Basically it requires user input from the console. But the program itself is run from a pipe
>
> i.e cmd1 | myprog.gambas
>
> PUBLIC SUB Main()
> DIM a AS Integer
> DIM inputline AS NEW String[]
> DIM ipt, f AS String
> a = -1
>
> WHILE NOT Eof(file.in)
> a += 1
> inputline.Resize(a + 1)
> LINE INPUT #file.In, inputline[a]
> WEND
>
>
> FOR EACH f IN inputline
>
> LINE INPUT ipt < -- at this point i get MMain.Main.21: #39: End of file
> PRINT #file.out, f & " " & ipt
>
> NEXT
> END
>
> How do I "reopen" standard input?
>
Not very easily :)
It would be easier to run your "cmd1" from within your Gambas
application, using Shell or Exec, and collect its output into a file
which you then load.
(In C, you could 'close(0); fd = open("/dev/tty");' to close the
current connection on stdin, and re-open with the user's terminal.
You could still have the problem of knowing when cmd1 has finished
outputting data though.)
Mike
More information about the User
mailing list