How can i achieve pstree -sup $$ just with ps?

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











up vote
-1
down vote

favorite












how can i achieve pstree -sup $$ just using ps?
Tried ps h -a -o pid,user,comm= $$ but can't figure it out,
how to get the "process-chain"... Do I need a shell-script for it?



Thx
Johnny







share|improve this question























    up vote
    -1
    down vote

    favorite












    how can i achieve pstree -sup $$ just using ps?
    Tried ps h -a -o pid,user,comm= $$ but can't figure it out,
    how to get the "process-chain"... Do I need a shell-script for it?



    Thx
    Johnny







    share|improve this question





















      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      how can i achieve pstree -sup $$ just using ps?
      Tried ps h -a -o pid,user,comm= $$ but can't figure it out,
      how to get the "process-chain"... Do I need a shell-script for it?



      Thx
      Johnny







      share|improve this question











      how can i achieve pstree -sup $$ just using ps?
      Tried ps h -a -o pid,user,comm= $$ but can't figure it out,
      how to get the "process-chain"... Do I need a shell-script for it?



      Thx
      Johnny









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 7 at 16:04









      Johnny

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          #!/bin/bash

          PID=$(ps -h -o pid $1)
          while true;do
          user=$(ps h -o user $PID)
          cmd=$(ps h -o comm= $PID)
          echo -e "$PID t ($cmd,$user)"
          [ $PID != 1 ] || break
          PID=$(ps h -o ppid $PID);
          done;
          exit 0





          share|improve this answer























          • A bit of comments, explanations will make this answer much better
            – Romeo Ninov
            Jun 8 at 18:18










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f448461%2fhow-can-i-achieve-pstree-sup-just-with-ps%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
          0
          down vote













          #!/bin/bash

          PID=$(ps -h -o pid $1)
          while true;do
          user=$(ps h -o user $PID)
          cmd=$(ps h -o comm= $PID)
          echo -e "$PID t ($cmd,$user)"
          [ $PID != 1 ] || break
          PID=$(ps h -o ppid $PID);
          done;
          exit 0





          share|improve this answer























          • A bit of comments, explanations will make this answer much better
            – Romeo Ninov
            Jun 8 at 18:18














          up vote
          0
          down vote













          #!/bin/bash

          PID=$(ps -h -o pid $1)
          while true;do
          user=$(ps h -o user $PID)
          cmd=$(ps h -o comm= $PID)
          echo -e "$PID t ($cmd,$user)"
          [ $PID != 1 ] || break
          PID=$(ps h -o ppid $PID);
          done;
          exit 0





          share|improve this answer























          • A bit of comments, explanations will make this answer much better
            – Romeo Ninov
            Jun 8 at 18:18












          up vote
          0
          down vote










          up vote
          0
          down vote









          #!/bin/bash

          PID=$(ps -h -o pid $1)
          while true;do
          user=$(ps h -o user $PID)
          cmd=$(ps h -o comm= $PID)
          echo -e "$PID t ($cmd,$user)"
          [ $PID != 1 ] || break
          PID=$(ps h -o ppid $PID);
          done;
          exit 0





          share|improve this answer















          #!/bin/bash

          PID=$(ps -h -o pid $1)
          while true;do
          user=$(ps h -o user $PID)
          cmd=$(ps h -o comm= $PID)
          echo -e "$PID t ($cmd,$user)"
          [ $PID != 1 ] || break
          PID=$(ps h -o ppid $PID);
          done;
          exit 0






          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jun 8 at 18:17









          Community♦

          1




          1











          answered Jun 8 at 16:55









          JohnnyPanic

          1




          1











          • A bit of comments, explanations will make this answer much better
            – Romeo Ninov
            Jun 8 at 18:18
















          • A bit of comments, explanations will make this answer much better
            – Romeo Ninov
            Jun 8 at 18:18















          A bit of comments, explanations will make this answer much better
          – Romeo Ninov
          Jun 8 at 18:18




          A bit of comments, explanations will make this answer much better
          – Romeo Ninov
          Jun 8 at 18:18












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448461%2fhow-can-i-achieve-pstree-sup-just-with-ps%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)