Display terminal command result in Desktop notification

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
5
down vote

favorite












I need to display the result of a terminal command in notification.



Notifications can be triggered by running:



notify-send "Notification message"


The command I have is:



sudo /opt/lampp/xampp start


which shows the following result in terminal:



Starting XAMPP for Linux 5.6.20-0...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...already running.
XAMPP: Starting ProFTPD...already running.


I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.



Thanks!










share|improve this question



























    up vote
    5
    down vote

    favorite












    I need to display the result of a terminal command in notification.



    Notifications can be triggered by running:



    notify-send "Notification message"


    The command I have is:



    sudo /opt/lampp/xampp start


    which shows the following result in terminal:



    Starting XAMPP for Linux 5.6.20-0...
    XAMPP: Starting Apache...already running.
    XAMPP: Starting MySQL...already running.
    XAMPP: Starting ProFTPD...already running.


    I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.



    Thanks!










    share|improve this question

























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      I need to display the result of a terminal command in notification.



      Notifications can be triggered by running:



      notify-send "Notification message"


      The command I have is:



      sudo /opt/lampp/xampp start


      which shows the following result in terminal:



      Starting XAMPP for Linux 5.6.20-0...
      XAMPP: Starting Apache...already running.
      XAMPP: Starting MySQL...already running.
      XAMPP: Starting ProFTPD...already running.


      I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.



      Thanks!










      share|improve this question















      I need to display the result of a terminal command in notification.



      Notifications can be triggered by running:



      notify-send "Notification message"


      The command I have is:



      sudo /opt/lampp/xampp start


      which shows the following result in terminal:



      Starting XAMPP for Linux 5.6.20-0...
      XAMPP: Starting Apache...already running.
      XAMPP: Starting MySQL...already running.
      XAMPP: Starting ProFTPD...already running.


      I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.



      Thanks!







      command-line gnome-terminal notification notify-send






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 19 at 21:22









      Zanna

      48k13119228




      48k13119228










      asked Apr 14 at 8:28









      M. Zeeshan

      283




      283




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          In most cases you can use notify-send with command substitution $(). For example:





          notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"


          Inside a scrip you can use a function to wrap the entire output:



          #!/bin/bash
          main() echo "Line 1"; echo "Line 2"; echo "Line 3";
          notify-send "Script output" "$(main)"


          If you need to run that function with sudo:



          notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"





          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1024904%2fdisplay-terminal-command-result-in-desktop-notification%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            8
            down vote



            accepted










            In most cases you can use notify-send with command substitution $(). For example:





            notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"


            Inside a scrip you can use a function to wrap the entire output:



            #!/bin/bash
            main() echo "Line 1"; echo "Line 2"; echo "Line 3";
            notify-send "Script output" "$(main)"


            If you need to run that function with sudo:



            notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"





            share|improve this answer


























              up vote
              8
              down vote



              accepted










              In most cases you can use notify-send with command substitution $(). For example:





              notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"


              Inside a scrip you can use a function to wrap the entire output:



              #!/bin/bash
              main() echo "Line 1"; echo "Line 2"; echo "Line 3";
              notify-send "Script output" "$(main)"


              If you need to run that function with sudo:



              notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"





              share|improve this answer
























                up vote
                8
                down vote



                accepted







                up vote
                8
                down vote



                accepted






                In most cases you can use notify-send with command substitution $(). For example:





                notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"


                Inside a scrip you can use a function to wrap the entire output:



                #!/bin/bash
                main() echo "Line 1"; echo "Line 2"; echo "Line 3";
                notify-send "Script output" "$(main)"


                If you need to run that function with sudo:



                notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"





                share|improve this answer














                In most cases you can use notify-send with command substitution $(). For example:





                notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"


                Inside a scrip you can use a function to wrap the entire output:



                #!/bin/bash
                main() echo "Line 1"; echo "Line 2"; echo "Line 3";
                notify-send "Script output" "$(main)"


                If you need to run that function with sudo:



                notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 15 at 7:07

























                answered Apr 14 at 8:42









                pa4080

                12.2k52255




                12.2k52255



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1024904%2fdisplay-terminal-command-result-in-desktop-notification%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Which professions warranted travel in Medieval times?

                    How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

                    Trouble downloading packages list due to a “Hash sum mismatch” error