lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> On Sep 12, 2018, at 9:30 PM, Russell Haley <russ.haley@gmail.com> wrote:
> 
> uses stdin and stdout. That means (in my understanding) that the process must be kept in the foreground for interaction

Could you perhaps redirect stdin and stdout in the first place? And then perhaps read & write to them directly for ‘interaction’ purpose?

E.g.:

os.execute( 'mkfifo output' )

local aWriter = assert( io.popen( 'sqlplus -S /NOLOG > output', 'w' ) )
local aReader = assert( io.open( 'output', 'r' ) )

assert( aWriter:write( 'connect schema/pass@instance', '\n' ) )
assert( aWriter:flush() )

assert( aWriter:write( 'prompt -8<-;', '\n' ) )
assert( aWriter:write( 'select * from user_users;', '\n' ) )
assert( aWriter:write( 'prompt ->8-;', '\n' ) )
assert( aWriter:flush() )

repeat
 local aLine = aReader:read()
 print( '*', aLine, aLine:len() )
until not aLine or aLine == '->8-'