Communication of two programs in linux.

Hi,
I am working on an interface for a shell-like program on linux (let's call the main program AA for now). AA is kind of like a compiler/interpreter and the user can interactively work with it via a unix shell and entering the AA commands.
My GUI which works under X-windows is supposed to communicate with AA. It should be able to run AA and pass the commands of the user to AA.
My question is how exactly this communication can be done. I believe the interface needs to create some kind of a virtual shell and call AA in that shell and send and receive streams of text/data that way. Is there any way to do it? I am not even sure where to start. Or is there anotehr way to do this?
Thanks,
Shahin,

Comments

  • I have never used or programmed for linux/unix so i cant be sure but what about command line arguments? For example start AA by typing 'AA runthiscommand'. In the main function of AA parse the command line arguments and execute commands found in the command line.

  • : Hi,
    : I am working on an interface for a shell-like program on linux (let's call the main program AA for now). AA is kind of like a compiler/interpreter and the user can interactively work with it via a unix shell and entering the AA commands.
    : My GUI which works under X-windows is supposed to communicate with AA. It should be able to run AA and pass the commands of the user to AA.
    : My question is how exactly this communication can be done. I believe the interface needs to create some kind of a virtual shell and call AA in that shell and send and receive streams of text/data that way. Is there any way to do it? I am not even sure where to start. Or is there anotehr way to do this?
    : Thanks,
    : Shahin,
    :

    Ok, the steps to do this would be:
    "fork" ur program
    one of the process invokes AA
    the other invokes the GUI
    and...
    u can now send signals to AA from GUI (because u know the process ID)or at least, at this point, u are closer to solve the problem.

    i suggest u to read about process in linux...
  • Shahin--

    As usual, the answer is "it depends"...in this case, on what kind of data you need to pass between the GUI and AA.

    You don't need a virtual shell, and you don't want to use one for performance reasons. Your GUI should directly fork and exec AA.

    Now your options:
    --As mentioned above, you can use command-line arguments if you have only a few parameters to pass. The GUI includes these in the exec call, and AA reads them from its (argc argv[]) arguments.
    -- Also as mentioned above, if you need to pass only conrol information, you can use signals between the GUI and AA
    -- If you have substantial amounts of data to be transferred back and forth, you will need to select one of the available Unix IPC mechanisms. I suggest a named pipe (called FIFO in some Unix variants) as the simplest...just a stream of data (if it's more structured, you might also consider the msg(2) IPC)). One proc opens the named pipe to write, the other to read, and you're home free. (Use a second pipe for reverse channel communications).

    Good luck!

    Tom Cook

    : Hi,
    : I am working on an interface for a shell-like program on linux (let's call the main program AA for now). AA is kind of like a compiler/interpreter and the user can interactively work with it via a unix shell and entering the AA commands.
    : My GUI which works under X-windows is supposed to communicate with AA. It should be able to run AA and pass the commands of the user to AA.
    : My question is how exactly this communication can be done. I believe the interface needs to create some kind of a virtual shell and call AA in that shell and send and receive streams of text/data that way. Is there any way to do it? I am not even sure where to start. Or is there anotehr way to do this?
    : Thanks,
    : Shahin,
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories