Can't run a background process and other command from bash in one line: unxepected token `;' [duplicate]

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





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








1
















This question already has an answer here:



  • How can one run multiple programs in the background with single command?

    3 answers



I have a program that receives an argument and prints it every second:



~# ./myapp 234
234
234
234
234
...


I want to be able to run it in the background and right after a shell but it must be in one line (I don't want to explain why I need it because I don't want to make the discussion too complicated right now).



This is what I tried and the error I received:



~# bash -c "./myapp 234 &; sh" 
bash: -c: line 0: syntax error near unexpected token `;'
bash: -c: line 0: `./myapp 234 &; sh'


I also tried with && as separator:



~# bash -c "./myapp 234 & && sh" 
bash: -c: line 0: syntax error near unexpected token `&&'
bash: -c: line 0: `./myapp 234 & && sh'


Any idea how I can solve it?



EDIT:

Thanks to @roaima.

I also found a link that talks about it:
How to run a program in background and also using && to execute another command










share|improve this question















marked as duplicate by ilkkachu bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 12 at 11:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























    1
















    This question already has an answer here:



    • How can one run multiple programs in the background with single command?

      3 answers



    I have a program that receives an argument and prints it every second:



    ~# ./myapp 234
    234
    234
    234
    234
    ...


    I want to be able to run it in the background and right after a shell but it must be in one line (I don't want to explain why I need it because I don't want to make the discussion too complicated right now).



    This is what I tried and the error I received:



    ~# bash -c "./myapp 234 &; sh" 
    bash: -c: line 0: syntax error near unexpected token `;'
    bash: -c: line 0: `./myapp 234 &; sh'


    I also tried with && as separator:



    ~# bash -c "./myapp 234 & && sh" 
    bash: -c: line 0: syntax error near unexpected token `&&'
    bash: -c: line 0: `./myapp 234 & && sh'


    Any idea how I can solve it?



    EDIT:

    Thanks to @roaima.

    I also found a link that talks about it:
    How to run a program in background and also using && to execute another command










    share|improve this question















    marked as duplicate by ilkkachu bash
    Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Mar 12 at 11:12


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      1












      1








      1









      This question already has an answer here:



      • How can one run multiple programs in the background with single command?

        3 answers



      I have a program that receives an argument and prints it every second:



      ~# ./myapp 234
      234
      234
      234
      234
      ...


      I want to be able to run it in the background and right after a shell but it must be in one line (I don't want to explain why I need it because I don't want to make the discussion too complicated right now).



      This is what I tried and the error I received:



      ~# bash -c "./myapp 234 &; sh" 
      bash: -c: line 0: syntax error near unexpected token `;'
      bash: -c: line 0: `./myapp 234 &; sh'


      I also tried with && as separator:



      ~# bash -c "./myapp 234 & && sh" 
      bash: -c: line 0: syntax error near unexpected token `&&'
      bash: -c: line 0: `./myapp 234 & && sh'


      Any idea how I can solve it?



      EDIT:

      Thanks to @roaima.

      I also found a link that talks about it:
      How to run a program in background and also using && to execute another command










      share|improve this question

















      This question already has an answer here:



      • How can one run multiple programs in the background with single command?

        3 answers



      I have a program that receives an argument and prints it every second:



      ~# ./myapp 234
      234
      234
      234
      234
      ...


      I want to be able to run it in the background and right after a shell but it must be in one line (I don't want to explain why I need it because I don't want to make the discussion too complicated right now).



      This is what I tried and the error I received:



      ~# bash -c "./myapp 234 &; sh" 
      bash: -c: line 0: syntax error near unexpected token `;'
      bash: -c: line 0: `./myapp 234 &; sh'


      I also tried with && as separator:



      ~# bash -c "./myapp 234 & && sh" 
      bash: -c: line 0: syntax error near unexpected token `&&'
      bash: -c: line 0: `./myapp 234 & && sh'


      Any idea how I can solve it?



      EDIT:

      Thanks to @roaima.

      I also found a link that talks about it:
      How to run a program in background and also using && to execute another command





      This question already has an answer here:



      • How can one run multiple programs in the background with single command?

        3 answers







      bash background-process






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 12 at 11:02







      E235

















      asked Mar 12 at 10:41









      E235E235

      1345




      1345




      marked as duplicate by ilkkachu bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 12 at 11:12


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by ilkkachu bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 12 at 11:12


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          1 Answer
          1






          active

          oldest

          votes


















          2














          & is a statement terminator, so you don't need the ; too.



          bash -c "./myapp 234 & sh"


          Although I'm not entirely sure why you'd want to run sh from bash. Seems a backwards step to me.






          share|improve this answer























          • Oh cool, thanks. It works.

            – E235
            Mar 12 at 10:52

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          & is a statement terminator, so you don't need the ; too.



          bash -c "./myapp 234 & sh"


          Although I'm not entirely sure why you'd want to run sh from bash. Seems a backwards step to me.






          share|improve this answer























          • Oh cool, thanks. It works.

            – E235
            Mar 12 at 10:52















          2














          & is a statement terminator, so you don't need the ; too.



          bash -c "./myapp 234 & sh"


          Although I'm not entirely sure why you'd want to run sh from bash. Seems a backwards step to me.






          share|improve this answer























          • Oh cool, thanks. It works.

            – E235
            Mar 12 at 10:52













          2












          2








          2







          & is a statement terminator, so you don't need the ; too.



          bash -c "./myapp 234 & sh"


          Although I'm not entirely sure why you'd want to run sh from bash. Seems a backwards step to me.






          share|improve this answer













          & is a statement terminator, so you don't need the ; too.



          bash -c "./myapp 234 & sh"


          Although I'm not entirely sure why you'd want to run sh from bash. Seems a backwards step to me.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 12 at 10:46









          roaimaroaima

          46.1k758124




          46.1k758124












          • Oh cool, thanks. It works.

            – E235
            Mar 12 at 10:52

















          • Oh cool, thanks. It works.

            – E235
            Mar 12 at 10:52
















          Oh cool, thanks. It works.

          – E235
          Mar 12 at 10:52





          Oh cool, thanks. It works.

          – E235
          Mar 12 at 10:52


          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)