ps command return nothing in function

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











up vote
1
down vote

favorite












I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')



And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.



What could be the reason for the specific works on Suse and how can I fix it?







share|improve this question






















  • SUSE as well as Ubuntu has pidof, see here.
    – dessert
    Nov 9 '17 at 17:00







  • 2




    You cannot have spaces around = in a variable assignment.
    – glenn jackman
    Nov 9 '17 at 17:04










  • This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
    – creedqq
    Nov 9 '17 at 17:06














up vote
1
down vote

favorite












I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')



And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.



What could be the reason for the specific works on Suse and how can I fix it?







share|improve this question






















  • SUSE as well as Ubuntu has pidof, see here.
    – dessert
    Nov 9 '17 at 17:00







  • 2




    You cannot have spaces around = in a variable assignment.
    – glenn jackman
    Nov 9 '17 at 17:04










  • This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
    – creedqq
    Nov 9 '17 at 17:06












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')



And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.



What could be the reason for the specific works on Suse and how can I fix it?







share|improve this question














I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')



And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.



What could be the reason for the specific works on Suse and how can I fix it?









share|improve this question













share|improve this question




share|improve this question








edited Nov 9 '17 at 18:26









Jeff Schaller

32k849109




32k849109










asked Nov 9 '17 at 16:56









creedqq

82




82











  • SUSE as well as Ubuntu has pidof, see here.
    – dessert
    Nov 9 '17 at 17:00







  • 2




    You cannot have spaces around = in a variable assignment.
    – glenn jackman
    Nov 9 '17 at 17:04










  • This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
    – creedqq
    Nov 9 '17 at 17:06
















  • SUSE as well as Ubuntu has pidof, see here.
    – dessert
    Nov 9 '17 at 17:00







  • 2




    You cannot have spaces around = in a variable assignment.
    – glenn jackman
    Nov 9 '17 at 17:04










  • This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
    – creedqq
    Nov 9 '17 at 17:06















SUSE as well as Ubuntu has pidof, see here.
– dessert
Nov 9 '17 at 17:00





SUSE as well as Ubuntu has pidof, see here.
– dessert
Nov 9 '17 at 17:00





2




2




You cannot have spaces around = in a variable assignment.
– glenn jackman
Nov 9 '17 at 17:04




You cannot have spaces around = in a variable assignment.
– glenn jackman
Nov 9 '17 at 17:04












This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
– creedqq
Nov 9 '17 at 17:06




This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
– creedqq
Nov 9 '17 at 17:06










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










You need to use pgrep instead of ps axf if you want to use it with watch command. There is more extended explanation here






share|improve this answer






















    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%2f403565%2fps-command-return-nothing-in-function%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
    3
    down vote



    accepted










    You need to use pgrep instead of ps axf if you want to use it with watch command. There is more extended explanation here






    share|improve this answer


























      up vote
      3
      down vote



      accepted










      You need to use pgrep instead of ps axf if you want to use it with watch command. There is more extended explanation here






      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        You need to use pgrep instead of ps axf if you want to use it with watch command. There is more extended explanation here






        share|improve this answer














        You need to use pgrep instead of ps axf if you want to use it with watch command. There is more extended explanation here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 9 '17 at 17:11









        fpmurphy1

        2,231915




        2,231915










        answered Nov 9 '17 at 17:04









        evilsun

        462




        462



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f403565%2fps-command-return-nothing-in-function%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?