Integrating bash with a C program

From: David Colby (dlcolby_at_hotmail.com)
Date: 05/26/04

  • Next message: Benny Hill: "Re: Which develop tool do you use for linux?"
    Date: 25 May 2004 17:40:40 -0700
    
    

    I have been experimenting with this one for a while now, and can't
    seem to come up with a solution.
    What I want to do is create an application, ASYNCOUT that runs in the
    background and monitors a named pipe. Other processes would then be
    able to output asynchronous messages to the terminal by writing to the
    pipe. My goal was to have ASYNCOUT behave nicely, and only output to
    the terminal when the user was not in the middle of typing something
    (or in the middle of executing something, like ls or tail).
    First question: If somebody knows the proper way to do this, let me
    know!
    Otherwise, my next question relates to my attempted solution.

    The way that I attempted to solve this was to write an app that would
    montitor standard output for the prompt. Whenever the prompt is
    detected, then queued asynchronous messages could be output. The app
    would be started by:
    sh > ASYNCOUT
    The ASYNCOUT program would forward stdout to the terminal, while
    looking for the prompt. With this method, I see the output of ls (and
    similar builtins and programs), but I don't see the prompt.

    (Other solutions that I've thought of: modifying the shell or writing
    my own simple shell. These were both thrown out because they limited
    the user to one shell (and potentially limited a lot of
    functionality). Incidentally, this is an embedded, closed system, so I
    am in complete control of everything that is running in the system.

    Thanks for any help,
    David


  • Next message: Benny Hill: "Re: Which develop tool do you use for linux?"

    Relevant Pages

    • Re: Integrating bash with a C program
      ... My goal was to have ASYNCOUT behave nicely, ... > montitor standard output for the prompt. ... then queued asynchronous messages could be output. ... > my own simple shell. ...
      (comp.os.linux.development.apps)
    • Re: Ausgabeumleitung von Transferstatistik
      ... Shell kommt um einen neuen Prompt anzuzeigen und nicht vom sftp Kommando ... ohne abschließenden Newline beim Schließen geflusht, ... vielleicht schreibt sftp keine Verlaufsanzeige, ...
      (de.comp.os.unix.shell)
    • Re: Net::SSH::Perl -- can I capture the command prompt?
      ... actual interactive shell, I just want to capture the ... actual command prompt upon logging in. ... a Cisco router via a telnet or SSH shell, ... "Router#" tells you that you're in configuration mode. ...
      (comp.lang.perl.misc)
    • Re: Disk Druid - Fedora flame #1
      ... The only prompt I had to answer was ... As soon as the second stage installer fires up, ... If you are doing a network install, you'll need to provide your network info ... so it can get the second stage -- but it still starts the shell ...
      (Fedora)
    • Re: problem with exit while using nohup
      ... when you run any command ending with &, it runs in background, that shell does not wait till it gets over and shell prompt is displayed immediately. ... as it is evident, the exit should cause the script to terminate,hence ...
      (comp.unix.shell)