Playing sound on local computer after command in SSH connection





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







3















I'm in a ssh connection and I would like to play a sound after a command completes (not on the server where I connected).



Something:



ssh me@somewhere.com
make && play-sound-local


I have built-in pc-speaker disabled so echo -e "a" doesn't work.



Any suggestions?










share|improve this question

























  • Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

    – tanius
    Jan 31 at 22:19


















3















I'm in a ssh connection and I would like to play a sound after a command completes (not on the server where I connected).



Something:



ssh me@somewhere.com
make && play-sound-local


I have built-in pc-speaker disabled so echo -e "a" doesn't work.



Any suggestions?










share|improve this question

























  • Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

    – tanius
    Jan 31 at 22:19














3












3








3


1






I'm in a ssh connection and I would like to play a sound after a command completes (not on the server where I connected).



Something:



ssh me@somewhere.com
make && play-sound-local


I have built-in pc-speaker disabled so echo -e "a" doesn't work.



Any suggestions?










share|improve this question
















I'm in a ssh connection and I would like to play a sound after a command completes (not on the server where I connected).



Something:



ssh me@somewhere.com
make && play-sound-local


I have built-in pc-speaker disabled so echo -e "a" doesn't work.



Any suggestions?







ssh audio linux-mint ubuntu-9.10






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 17 '14 at 11:35









Der Hochstapler

68.5k50232288




68.5k50232288










asked Apr 4 '10 at 19:08









EgonEgon

2,28811215




2,28811215













  • Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

    – tanius
    Jan 31 at 22:19



















  • Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

    – tanius
    Jan 31 at 22:19

















Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

– tanius
Jan 31 at 22:19





Very similar question, with answer: "Playing a sound/notification in finch over ssh on my local machine".

– tanius
Jan 31 at 22:19










3 Answers
3






active

oldest

votes


















1














You can configure PulseAudio to allow network connections, then use ssh port forwarding and paplay -s on the remote side to send audio back through the ssh connection. Note that the audio may be delayed or stutter based on the fidelity of the audio and the speed of the connection.






share|improve this answer































    1














    Set up primitive server (for example, on port 1234) that plays sound on local computer when someone connects, and forward that port to remote server.



    On local machine:



    nc -l -p 1234 -e "mplayer sound.ogg"


    then



    ssh -L 1234:localhost:12345 me@somewhere.com
    make && nc localhost 12345


    PS: you should use ; instead of && if you want to be notified even when make failed.






    share|improve this answer































      1














      (This is the answer by @xzfc with some corrections.)





      1. Install ncat on your client and server machine. Because nc in usual distributions (Debian, Ubuntu) does not have the options to execute commands (-c / -e) which we need.



        apt install nmap



      2. On your local machine, set up a server that will execute a command to play a sound when a connection is established to it:



        ncat --sh-exec "paplay /usr/share/sounds/freedesktop/stereo/complete.oga" 
        --keep-open --listen localhost 10009


        Or use the equivalent shorthand command:



        ncat -klc "paplay file.oga" localhost 10009



      3. SSH into your remote host in such a way that a reverse tunnel is established from port 10008 of the remote host to port 10009 on your local machine (where your server is listening):



        ssh -R 10008:localhost:10009 me@somewhere.com



      4. Execute your make command as follows in the SSH shell:



        make; ncat --idle-timeout 1s localhost 10008



      How it works



      After the make command (whether successful or not), the ncat command establishes a connection to port 10008 on the remote host, which SSH forwards to port 10009 on your local machine, where your server listens and will play a sound when the connection is made. After the connection has been established, we no longer need it, so it is closed after --idle-timeout 1s. This will show the shell prompt again instead of a "hanging" ncat command, making it apparent that your SSH command chain really finished.



      The SSH reverse tunneling makes this work in spite of any routers / firewalls / NAT between your local machine and the remote machine. (Otherwise you would have to set up port forwarding rules in your router, or have a local machine exposed to the Internet.)



      Security



      We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). So even if you are not behind a firewall, your port 10009 is not exposed to anyone on the Internet.






      share|improve this answer


























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        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',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f127376%2fplaying-sound-on-local-computer-after-command-in-ssh-connection%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        You can configure PulseAudio to allow network connections, then use ssh port forwarding and paplay -s on the remote side to send audio back through the ssh connection. Note that the audio may be delayed or stutter based on the fidelity of the audio and the speed of the connection.






        share|improve this answer




























          1














          You can configure PulseAudio to allow network connections, then use ssh port forwarding and paplay -s on the remote side to send audio back through the ssh connection. Note that the audio may be delayed or stutter based on the fidelity of the audio and the speed of the connection.






          share|improve this answer


























            1












            1








            1







            You can configure PulseAudio to allow network connections, then use ssh port forwarding and paplay -s on the remote side to send audio back through the ssh connection. Note that the audio may be delayed or stutter based on the fidelity of the audio and the speed of the connection.






            share|improve this answer













            You can configure PulseAudio to allow network connections, then use ssh port forwarding and paplay -s on the remote side to send audio back through the ssh connection. Note that the audio may be delayed or stutter based on the fidelity of the audio and the speed of the connection.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 4 '10 at 19:18









            Ignacio Vazquez-AbramsIgnacio Vazquez-Abrams

            96.9k6156212




            96.9k6156212

























                1














                Set up primitive server (for example, on port 1234) that plays sound on local computer when someone connects, and forward that port to remote server.



                On local machine:



                nc -l -p 1234 -e "mplayer sound.ogg"


                then



                ssh -L 1234:localhost:12345 me@somewhere.com
                make && nc localhost 12345


                PS: you should use ; instead of && if you want to be notified even when make failed.






                share|improve this answer




























                  1














                  Set up primitive server (for example, on port 1234) that plays sound on local computer when someone connects, and forward that port to remote server.



                  On local machine:



                  nc -l -p 1234 -e "mplayer sound.ogg"


                  then



                  ssh -L 1234:localhost:12345 me@somewhere.com
                  make && nc localhost 12345


                  PS: you should use ; instead of && if you want to be notified even when make failed.






                  share|improve this answer


























                    1












                    1








                    1







                    Set up primitive server (for example, on port 1234) that plays sound on local computer when someone connects, and forward that port to remote server.



                    On local machine:



                    nc -l -p 1234 -e "mplayer sound.ogg"


                    then



                    ssh -L 1234:localhost:12345 me@somewhere.com
                    make && nc localhost 12345


                    PS: you should use ; instead of && if you want to be notified even when make failed.






                    share|improve this answer













                    Set up primitive server (for example, on port 1234) that plays sound on local computer when someone connects, and forward that port to remote server.



                    On local machine:



                    nc -l -p 1234 -e "mplayer sound.ogg"


                    then



                    ssh -L 1234:localhost:12345 me@somewhere.com
                    make && nc localhost 12345


                    PS: you should use ; instead of && if you want to be notified even when make failed.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 17 '14 at 12:02









                    xzfcxzfc

                    39124




                    39124























                        1














                        (This is the answer by @xzfc with some corrections.)





                        1. Install ncat on your client and server machine. Because nc in usual distributions (Debian, Ubuntu) does not have the options to execute commands (-c / -e) which we need.



                          apt install nmap



                        2. On your local machine, set up a server that will execute a command to play a sound when a connection is established to it:



                          ncat --sh-exec "paplay /usr/share/sounds/freedesktop/stereo/complete.oga" 
                          --keep-open --listen localhost 10009


                          Or use the equivalent shorthand command:



                          ncat -klc "paplay file.oga" localhost 10009



                        3. SSH into your remote host in such a way that a reverse tunnel is established from port 10008 of the remote host to port 10009 on your local machine (where your server is listening):



                          ssh -R 10008:localhost:10009 me@somewhere.com



                        4. Execute your make command as follows in the SSH shell:



                          make; ncat --idle-timeout 1s localhost 10008



                        How it works



                        After the make command (whether successful or not), the ncat command establishes a connection to port 10008 on the remote host, which SSH forwards to port 10009 on your local machine, where your server listens and will play a sound when the connection is made. After the connection has been established, we no longer need it, so it is closed after --idle-timeout 1s. This will show the shell prompt again instead of a "hanging" ncat command, making it apparent that your SSH command chain really finished.



                        The SSH reverse tunneling makes this work in spite of any routers / firewalls / NAT between your local machine and the remote machine. (Otherwise you would have to set up port forwarding rules in your router, or have a local machine exposed to the Internet.)



                        Security



                        We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). So even if you are not behind a firewall, your port 10009 is not exposed to anyone on the Internet.






                        share|improve this answer






























                          1














                          (This is the answer by @xzfc with some corrections.)





                          1. Install ncat on your client and server machine. Because nc in usual distributions (Debian, Ubuntu) does not have the options to execute commands (-c / -e) which we need.



                            apt install nmap



                          2. On your local machine, set up a server that will execute a command to play a sound when a connection is established to it:



                            ncat --sh-exec "paplay /usr/share/sounds/freedesktop/stereo/complete.oga" 
                            --keep-open --listen localhost 10009


                            Or use the equivalent shorthand command:



                            ncat -klc "paplay file.oga" localhost 10009



                          3. SSH into your remote host in such a way that a reverse tunnel is established from port 10008 of the remote host to port 10009 on your local machine (where your server is listening):



                            ssh -R 10008:localhost:10009 me@somewhere.com



                          4. Execute your make command as follows in the SSH shell:



                            make; ncat --idle-timeout 1s localhost 10008



                          How it works



                          After the make command (whether successful or not), the ncat command establishes a connection to port 10008 on the remote host, which SSH forwards to port 10009 on your local machine, where your server listens and will play a sound when the connection is made. After the connection has been established, we no longer need it, so it is closed after --idle-timeout 1s. This will show the shell prompt again instead of a "hanging" ncat command, making it apparent that your SSH command chain really finished.



                          The SSH reverse tunneling makes this work in spite of any routers / firewalls / NAT between your local machine and the remote machine. (Otherwise you would have to set up port forwarding rules in your router, or have a local machine exposed to the Internet.)



                          Security



                          We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). So even if you are not behind a firewall, your port 10009 is not exposed to anyone on the Internet.






                          share|improve this answer




























                            1












                            1








                            1







                            (This is the answer by @xzfc with some corrections.)





                            1. Install ncat on your client and server machine. Because nc in usual distributions (Debian, Ubuntu) does not have the options to execute commands (-c / -e) which we need.



                              apt install nmap



                            2. On your local machine, set up a server that will execute a command to play a sound when a connection is established to it:



                              ncat --sh-exec "paplay /usr/share/sounds/freedesktop/stereo/complete.oga" 
                              --keep-open --listen localhost 10009


                              Or use the equivalent shorthand command:



                              ncat -klc "paplay file.oga" localhost 10009



                            3. SSH into your remote host in such a way that a reverse tunnel is established from port 10008 of the remote host to port 10009 on your local machine (where your server is listening):



                              ssh -R 10008:localhost:10009 me@somewhere.com



                            4. Execute your make command as follows in the SSH shell:



                              make; ncat --idle-timeout 1s localhost 10008



                            How it works



                            After the make command (whether successful or not), the ncat command establishes a connection to port 10008 on the remote host, which SSH forwards to port 10009 on your local machine, where your server listens and will play a sound when the connection is made. After the connection has been established, we no longer need it, so it is closed after --idle-timeout 1s. This will show the shell prompt again instead of a "hanging" ncat command, making it apparent that your SSH command chain really finished.



                            The SSH reverse tunneling makes this work in spite of any routers / firewalls / NAT between your local machine and the remote machine. (Otherwise you would have to set up port forwarding rules in your router, or have a local machine exposed to the Internet.)



                            Security



                            We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). So even if you are not behind a firewall, your port 10009 is not exposed to anyone on the Internet.






                            share|improve this answer















                            (This is the answer by @xzfc with some corrections.)





                            1. Install ncat on your client and server machine. Because nc in usual distributions (Debian, Ubuntu) does not have the options to execute commands (-c / -e) which we need.



                              apt install nmap



                            2. On your local machine, set up a server that will execute a command to play a sound when a connection is established to it:



                              ncat --sh-exec "paplay /usr/share/sounds/freedesktop/stereo/complete.oga" 
                              --keep-open --listen localhost 10009


                              Or use the equivalent shorthand command:



                              ncat -klc "paplay file.oga" localhost 10009



                            3. SSH into your remote host in such a way that a reverse tunnel is established from port 10008 of the remote host to port 10009 on your local machine (where your server is listening):



                              ssh -R 10008:localhost:10009 me@somewhere.com



                            4. Execute your make command as follows in the SSH shell:



                              make; ncat --idle-timeout 1s localhost 10008



                            How it works



                            After the make command (whether successful or not), the ncat command establishes a connection to port 10008 on the remote host, which SSH forwards to port 10009 on your local machine, where your server listens and will play a sound when the connection is made. After the connection has been established, we no longer need it, so it is closed after --idle-timeout 1s. This will show the shell prompt again instead of a "hanging" ncat command, making it apparent that your SSH command chain really finished.



                            The SSH reverse tunneling makes this work in spite of any routers / firewalls / NAT between your local machine and the remote machine. (Otherwise you would have to set up port forwarding rules in your router, or have a local machine exposed to the Internet.)



                            Security



                            We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). So even if you are not behind a firewall, your port 10009 is not exposed to anyone on the Internet.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 2 at 11:15

























                            answered Jan 31 at 21:52









                            taniustanius

                            4501615




                            4501615






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f127376%2fplaying-sound-on-local-computer-after-command-in-ssh-connection%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                                Alcedinidae

                                Can an atomic nucleus contain both particles and antiparticles? [duplicate]