how to avoid garbage option error on grep commandConditional grep without quiet optionBash command not found...

Who's the random kid standing in the gathering at the end?

Don’t seats that recline flat defeat the purpose of having seatbelts?

A Paper Record is What I Hamper

Negative Resistance

A strange hotel

As an international instructor, should I openly talk about my accent?

How to not starve gigantic beasts

Can a stored procedure reference the database in which it is stored?

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

How do I reattach a shelf to the wall when it ripped out of the wall?

"The cow" OR "a cow" OR "cows" in this context

Why do games have consumables?

Mistake in years of experience in resume?

Could moose/elk survive in the Amazon forest?

How can I practically buy stocks?

What is /etc/mtab in Linux?

How can I get rid of an unhelpful parallel branch when unpivoting a single row?

Check if a string is entirely made of the same substring

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

What was Apollo 13's "Little Jolt" after MECO?

Find the identical rows in a matrix

Combinatorics problem, right solution?

An array in a equation with curly braces in both sides

Is there a word for the censored part of a video?



how to avoid garbage option error on grep command


Conditional grep without quiet optionBash command not found due to stray garbage charactersGarbage in bash session log file. (using script command)How to grep AND pattern with pipeGrep Command execution within a loop gives errorRedirect grep error output inside if conditionalHow to avoid error-message during the execution of a bash script?How to avoid `command not found` error when re-sourcing bash configuration with a key binding?How to display the command and avoid code injectionHow can I fix my script to avoid “[Yes: command not found”?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















i need to check whether a process is running or not on server. But challenge is , the keyword I am using is not the userid , it's part of the o/p or ps command.



When i am running as ps -ef | grep -v $$ | grep xenon , I am getting as




error: garbage option



Usage: ps [options]



Try 'ps --help ' or 'ps --help
' for additional help text.



For more details see ps(1). xenon is not running, please check
error: garbage option




On server , some reason I see no o/p for pgrep , which will resolve my challenge. He is the o/p from server.



$ps -ef | grep xenon
venom 3157 95310 0 23:08 pts/5 00:00:00 grep --color=auto xenon
root 45943 1 0 Apr12 ? 00:17:47 /opt/xenon/sganet/agent/lib64/sganetwatchdog -vm=/opt/xenon/sganet/agent/lib64/sganetos -logdir /opt/xenon/sganet/log -ini ../conf/ruxitwatchdog.ini
root 45981 45943 2 Apr12 ? 08:20:31 /opt/xenon/sganet/agent/lib64/sganetos -Dcom.compuware.apm.WatchDogTimeout=9000 -Dcom.compuware.apm.WatchDogPort=5000
$pgrep xenon
$pgrep -c xenon
0
$


Here is the script I wrote basically to check for validating multiple process running on the server.



#!/bin/bash
set +x
USER=`whoami`
#pg='ps -ef | grep -v $USER | '
pg='ps ax | grep -v grep | '
#--------function to check process ---------#
check_process() {

$pg $1 >/dev/null && echo -e "$1 is running" || echo -e "$1 is not running, please check "
}

#--------Checking process on the server---------#

echo -e "nn checking the processes"
check_process xenon
check_process upnew









share|improve this question































    0















    i need to check whether a process is running or not on server. But challenge is , the keyword I am using is not the userid , it's part of the o/p or ps command.



    When i am running as ps -ef | grep -v $$ | grep xenon , I am getting as




    error: garbage option



    Usage: ps [options]



    Try 'ps --help ' or 'ps --help
    ' for additional help text.



    For more details see ps(1). xenon is not running, please check
    error: garbage option




    On server , some reason I see no o/p for pgrep , which will resolve my challenge. He is the o/p from server.



    $ps -ef | grep xenon
    venom 3157 95310 0 23:08 pts/5 00:00:00 grep --color=auto xenon
    root 45943 1 0 Apr12 ? 00:17:47 /opt/xenon/sganet/agent/lib64/sganetwatchdog -vm=/opt/xenon/sganet/agent/lib64/sganetos -logdir /opt/xenon/sganet/log -ini ../conf/ruxitwatchdog.ini
    root 45981 45943 2 Apr12 ? 08:20:31 /opt/xenon/sganet/agent/lib64/sganetos -Dcom.compuware.apm.WatchDogTimeout=9000 -Dcom.compuware.apm.WatchDogPort=5000
    $pgrep xenon
    $pgrep -c xenon
    0
    $


    Here is the script I wrote basically to check for validating multiple process running on the server.



    #!/bin/bash
    set +x
    USER=`whoami`
    #pg='ps -ef | grep -v $USER | '
    pg='ps ax | grep -v grep | '
    #--------function to check process ---------#
    check_process() {

    $pg $1 >/dev/null && echo -e "$1 is running" || echo -e "$1 is not running, please check "
    }

    #--------Checking process on the server---------#

    echo -e "nn checking the processes"
    check_process xenon
    check_process upnew









    share|improve this question



























      0












      0








      0








      i need to check whether a process is running or not on server. But challenge is , the keyword I am using is not the userid , it's part of the o/p or ps command.



      When i am running as ps -ef | grep -v $$ | grep xenon , I am getting as




      error: garbage option



      Usage: ps [options]



      Try 'ps --help ' or 'ps --help
      ' for additional help text.



      For more details see ps(1). xenon is not running, please check
      error: garbage option




      On server , some reason I see no o/p for pgrep , which will resolve my challenge. He is the o/p from server.



      $ps -ef | grep xenon
      venom 3157 95310 0 23:08 pts/5 00:00:00 grep --color=auto xenon
      root 45943 1 0 Apr12 ? 00:17:47 /opt/xenon/sganet/agent/lib64/sganetwatchdog -vm=/opt/xenon/sganet/agent/lib64/sganetos -logdir /opt/xenon/sganet/log -ini ../conf/ruxitwatchdog.ini
      root 45981 45943 2 Apr12 ? 08:20:31 /opt/xenon/sganet/agent/lib64/sganetos -Dcom.compuware.apm.WatchDogTimeout=9000 -Dcom.compuware.apm.WatchDogPort=5000
      $pgrep xenon
      $pgrep -c xenon
      0
      $


      Here is the script I wrote basically to check for validating multiple process running on the server.



      #!/bin/bash
      set +x
      USER=`whoami`
      #pg='ps -ef | grep -v $USER | '
      pg='ps ax | grep -v grep | '
      #--------function to check process ---------#
      check_process() {

      $pg $1 >/dev/null && echo -e "$1 is running" || echo -e "$1 is not running, please check "
      }

      #--------Checking process on the server---------#

      echo -e "nn checking the processes"
      check_process xenon
      check_process upnew









      share|improve this question
















      i need to check whether a process is running or not on server. But challenge is , the keyword I am using is not the userid , it's part of the o/p or ps command.



      When i am running as ps -ef | grep -v $$ | grep xenon , I am getting as




      error: garbage option



      Usage: ps [options]



      Try 'ps --help ' or 'ps --help
      ' for additional help text.



      For more details see ps(1). xenon is not running, please check
      error: garbage option




      On server , some reason I see no o/p for pgrep , which will resolve my challenge. He is the o/p from server.



      $ps -ef | grep xenon
      venom 3157 95310 0 23:08 pts/5 00:00:00 grep --color=auto xenon
      root 45943 1 0 Apr12 ? 00:17:47 /opt/xenon/sganet/agent/lib64/sganetwatchdog -vm=/opt/xenon/sganet/agent/lib64/sganetos -logdir /opt/xenon/sganet/log -ini ../conf/ruxitwatchdog.ini
      root 45981 45943 2 Apr12 ? 08:20:31 /opt/xenon/sganet/agent/lib64/sganetos -Dcom.compuware.apm.WatchDogTimeout=9000 -Dcom.compuware.apm.WatchDogPort=5000
      $pgrep xenon
      $pgrep -c xenon
      0
      $


      Here is the script I wrote basically to check for validating multiple process running on the server.



      #!/bin/bash
      set +x
      USER=`whoami`
      #pg='ps -ef | grep -v $USER | '
      pg='ps ax | grep -v grep | '
      #--------function to check process ---------#
      check_process() {

      $pg $1 >/dev/null && echo -e "$1 is running" || echo -e "$1 is not running, please check "
      }

      #--------Checking process on the server---------#

      echo -e "nn checking the processes"
      check_process xenon
      check_process upnew






      bash shell-script ps






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 mins ago









      Rui F Ribeiro

      42.4k1485143




      42.4k1485143










      asked 11 mins ago









      VajraVajra

      82




      82






















          0






          active

          oldest

          votes












          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f515607%2fhow-to-avoid-garbage-option-error-on-grep-command%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f515607%2fhow-to-avoid-garbage-option-error-on-grep-command%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...