[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: use a string as stdin?
- From: Michal Kolodziejczyk <miko@...>
- Date: Tue, 23 Mar 2010 08:53:24 +0100
On 23.03.2010 08:44, Valerio Schiavoni wrote:
> hello,
> i execute a command-line program via popen. This command can receive
> input from stdin or from a file.
> The input parameter in my case is a string. Currently, I wrote the
> string on a temp file, and I specify the name
> of the file as a parameter to the command given to popen.
>
> Do you know if it's possible to play with stdin so that the string is
> set as the current stdin, so that I avoid to write on disk ?
Just use pipes:
$ echo "Long string"|lua -e 'print("String:", io.read("*a"))'
Regards,
miko