execute read command from var [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
How can we run a command stored in a variable?
3 answers
I want to add "debug" optio to my script, for that I added a read commands in specific places in the code. Basically it look like this:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE="read -p 'press any key to continue:'"
#calling it
${READ_USER_INPUT_IF_IN_DEBUG_MODE}
the screen output is not as desired;
sm2edolt01.corp.nyx.com:/home/oracle/nir >./a.sh
'press
Tried to replace the '
with "
as well.
bash shell-script
marked as duplicate by Kusalananda
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();
}
);
});
});
Nov 14 at 10:06
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 |
up vote
0
down vote
favorite
This question already has an answer here:
How can we run a command stored in a variable?
3 answers
I want to add "debug" optio to my script, for that I added a read commands in specific places in the code. Basically it look like this:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE="read -p 'press any key to continue:'"
#calling it
${READ_USER_INPUT_IF_IN_DEBUG_MODE}
the screen output is not as desired;
sm2edolt01.corp.nyx.com:/home/oracle/nir >./a.sh
'press
Tried to replace the '
with "
as well.
bash shell-script
marked as duplicate by Kusalananda
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();
}
);
});
});
Nov 14 at 10:06
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 |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How can we run a command stored in a variable?
3 answers
I want to add "debug" optio to my script, for that I added a read commands in specific places in the code. Basically it look like this:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE="read -p 'press any key to continue:'"
#calling it
${READ_USER_INPUT_IF_IN_DEBUG_MODE}
the screen output is not as desired;
sm2edolt01.corp.nyx.com:/home/oracle/nir >./a.sh
'press
Tried to replace the '
with "
as well.
bash shell-script
This question already has an answer here:
How can we run a command stored in a variable?
3 answers
I want to add "debug" optio to my script, for that I added a read commands in specific places in the code. Basically it look like this:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE="read -p 'press any key to continue:'"
#calling it
${READ_USER_INPUT_IF_IN_DEBUG_MODE}
the screen output is not as desired;
sm2edolt01.corp.nyx.com:/home/oracle/nir >./a.sh
'press
Tried to replace the '
with "
as well.
This question already has an answer here:
How can we run a command stored in a variable?
3 answers
bash shell-script
bash shell-script
edited Nov 14 at 10:11
Rui F Ribeiro
38.2k1475123
38.2k1475123
asked Nov 14 at 9:56
Nir
42521020
42521020
marked as duplicate by Kusalananda
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();
}
);
});
});
Nov 14 at 10:06
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 Kusalananda
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();
}
);
});
});
Nov 14 at 10:06
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
up vote
1
down vote
accepted
Quoting won't work, use any array:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE=(read -p 'press any key to continue:')
#calling it
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
See this page for more details on Bash arrays handling.
New contributor
One thing though. I need that the command"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting incommand not found
– Nir
9 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Quoting won't work, use any array:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE=(read -p 'press any key to continue:')
#calling it
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
See this page for more details on Bash arrays handling.
New contributor
One thing though. I need that the command"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting incommand not found
– Nir
9 hours ago
add a comment |
up vote
1
down vote
accepted
Quoting won't work, use any array:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE=(read -p 'press any key to continue:')
#calling it
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
See this page for more details on Bash arrays handling.
New contributor
One thing though. I need that the command"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting incommand not found
– Nir
9 hours ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Quoting won't work, use any array:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE=(read -p 'press any key to continue:')
#calling it
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
See this page for more details on Bash arrays handling.
New contributor
Quoting won't work, use any array:
#define it
READ_USER_INPUT_IF_IN_DEBUG_MODE=(read -p 'press any key to continue:')
#calling it
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
See this page for more details on Bash arrays handling.
New contributor
New contributor
answered Nov 14 at 10:02
Simon Sudler
1263
1263
New contributor
New contributor
One thing though. I need that the command"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting incommand not found
– Nir
9 hours ago
add a comment |
One thing though. I need that the command"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting incommand not found
– Nir
9 hours ago
One thing though. I need that the command
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting in command not found
– Nir
9 hours ago
One thing though. I need that the command
"${READ_USER_INPUT_IF_IN_DEBUG_MODE[@]}"
will not return error in case of empty variable. Setting it to empty string resulting in command not found
– Nir
9 hours ago
add a comment |