Skip to main content
Inspiring
December 4, 2017
Question

STDIN and STDOUT

  • December 4, 2017
  • 2 replies
  • 1696 views

Hello,

I need the ability to launch an AIR application using another program and communicate with that program using by listening to the STDIN and writing to the STDOUT.

I think STDIN/STDOUT could be blocked by Air ?

"trace()" not work


when I use in a native extension (Visual C++) :

Console::WriteLine("test");


it work with adt (debug mode) and not in a release Air app.

Thanks

This topic has been closed for replies.

2 replies

Inspiring
December 5, 2017

"as is" Adobe AIR does not manage its own standard streams like stdin, stderr and stdout

pol2095  wrote

I need the ability to launch an AIR application using another program and communicate with that program using by listening to the STDIN and writing to the STDOUT.

I would ask why do you need to do it like that?
and also on which operating system?

instead you should use the InvokeEvent
which should be able to pass arguments to your AIR application

and also a currentDirectory and a reason which could indicate how the AIR app was launched
eg. LOGIN | NOTIFICATION | OPEN_URL | STANDARD

and if you need to constantly exchange commands you should use sockets

to initiate a 2-way communication between your "command program" and the "Adobe AIR app"

eg.
command.exe air_app.exe -ip 127.0.1.1-port 123

air_app.exe will receive the InvokeEvent
with arguments = "-ip 127.0.1.1-port 123", currentDirectory = "<same directory as command.exe>"
and reason = "OPEN_URL"


and then use the ip/port to connect your socket between the 2 exe

pol2095Author
Inspiring
December 5, 2017

Windows cmd launch Air app and I need writing to the STDOUT for a return to the cmd.

Inspiring
December 6, 2017

You still don't explain why you have to do it like that ...

anyway, simple way: produce a AIR debug app and use trace()

more complex way use something like that

var filepath:String = "C:\\Windows\\System32\\cmd.exe";

var args:Vector.<String> = new Vector.<String>();

    args[0] = "/C";

    args[1] = "echo 'hello world'";

var file:File = new File( filepath );

var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

    startupInfo.executable = file;

    startupInfo.arguments = args;

var process:NativeProcess = new NativeProcess();

process.addEventListener( ProgressEvent.STANDARD_OUTPUT_DATA, onProcessOutput );

process.addEventListener( ProgressEvent.STANDARD_ERROR_DATA, onProcessError );

process.addEventListener( NativeProcessExitEvent.EXIT, onProcessExit );

process.addEventListener( IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onProcessIOError );

process.addEventListener( IOErrorEvent.STANDARD_ERROR_IO_ERROR, onProcessIOError );

process.start( startupInfo );

Inspiring
December 4, 2017

You did not ask a question.

pol2095Author
Inspiring
December 4, 2017

Is-it possible to use STDOUT in a release Air app when Air app is launched by another program ?