viewing bash output from another shell retrospectively












1















I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question























  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    2 hours ago











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    2 hours ago











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    2 hours ago
















1















I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question























  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    2 hours ago











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    2 hours ago











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    2 hours ago














1












1








1








I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question














I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?







linux bash shell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 hours ago









tomasz74tomasz74

122147




122147













  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    2 hours ago











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    2 hours ago











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    2 hours ago



















  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    2 hours ago











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    2 hours ago











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    2 hours ago

















Has the shell been run through a terminal (ie did you launch it from a GUI)?

– davidgo
2 hours ago





Has the shell been run through a terminal (ie did you launch it from a GUI)?

– davidgo
2 hours ago













You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

– QuickishFM
2 hours ago





You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

– QuickishFM
2 hours ago













@davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

– tomasz74
2 hours ago





@davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

– tomasz74
2 hours ago










2 Answers
2






active

oldest

votes


















3














There's this answer on ServerFault:




setterm can dump the contents of a Linux virtual console:



setterm -file log.txt -dump [ttynumbers]


However, it does not have access to the scrollback buffer, only to what's currently displayed.




This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



sudo setterm -file log.txt -dump 2





share|improve this answer

































    1














    While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



    Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






    share|improve this answer
























    • This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

      – davidgo
      4 mins ago











    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%2f1397590%2fviewing-bash-output-from-another-shell-retrospectively%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    There's this answer on ServerFault:




    setterm can dump the contents of a Linux virtual console:



    setterm -file log.txt -dump [ttynumbers]


    However, it does not have access to the scrollback buffer, only to what's currently displayed.




    This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



    sudo setterm -file log.txt -dump 2





    share|improve this answer






























      3














      There's this answer on ServerFault:




      setterm can dump the contents of a Linux virtual console:



      setterm -file log.txt -dump [ttynumbers]


      However, it does not have access to the scrollback buffer, only to what's currently displayed.




      This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



      sudo setterm -file log.txt -dump 2





      share|improve this answer




























        3












        3








        3







        There's this answer on ServerFault:




        setterm can dump the contents of a Linux virtual console:



        setterm -file log.txt -dump [ttynumbers]


        However, it does not have access to the scrollback buffer, only to what's currently displayed.




        This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



        sudo setterm -file log.txt -dump 2





        share|improve this answer















        There's this answer on ServerFault:




        setterm can dump the contents of a Linux virtual console:



        setterm -file log.txt -dump [ttynumbers]


        However, it does not have access to the scrollback buffer, only to what's currently displayed.




        This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



        sudo setterm -file log.txt -dump 2






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        Kamil MaciorowskiKamil Maciorowski

        26k155679




        26k155679

























            1














            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer
























            • This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              4 mins ago
















            1














            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer
























            • This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              4 mins ago














            1












            1








            1







            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer













            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 hours ago









            QuickishFMQuickishFM

            765




            765













            • This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              4 mins ago



















            • This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              4 mins ago

















            This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

            – davidgo
            4 mins ago





            This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

            – davidgo
            4 mins ago


















            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%2f1397590%2fviewing-bash-output-from-another-shell-retrospectively%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

            الفوسفات في المغرب

            Four equal circles intersect: What is the area of the small shaded portion and its height

            جامعة ليفربول