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

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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
bash background-process
marked as duplicate by ilkkachu
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.
add a comment |
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
bash background-process
marked as duplicate by ilkkachu
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.
add a comment |
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
bash background-process
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
bash background-process
edited Mar 12 at 11:02
E235
asked Mar 12 at 10:41
E235E235
1345
1345
marked as duplicate by ilkkachu
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
& 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.
Oh cool, thanks. It works.
– E235
Mar 12 at 10:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
& 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.
Oh cool, thanks. It works.
– E235
Mar 12 at 10:52
add a comment |
& 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.
Oh cool, thanks. It works.
– E235
Mar 12 at 10:52
add a comment |
& 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.
& 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.
answered Mar 12 at 10:46
roaimaroaima
46.1k758124
46.1k758124
Oh cool, thanks. It works.
– E235
Mar 12 at 10:52
add a comment |
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
add a comment |