Bash script failing with unknown option due to space in argument [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Why does my shell script choke on whitespace or other special characters?
4 answers
I am trying to run aws create lambda function. It goes as follows -
eval $(aws lambda create-function
--function-name $FUNCTION_NAME
--runtime $RUNTIME
--role $ROLE
--handler $HANDLER
--region $REGION
--zip-file $ZIP_FILE
--profile $PROFILE
--environment $env_variables)
All the variables come from command line. It is failing for env_variables. This gets constructed as -
env_variables="Variables=INPUT=$DAYS"
where DAYS is actually "20 days"
How can I avoid this space and pass my command successfully.
shell-script shell quoting
marked as duplicate by Gilles
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 4 '17 at 18:50
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:
Why does my shell script choke on whitespace or other special characters?
4 answers
I am trying to run aws create lambda function. It goes as follows -
eval $(aws lambda create-function
--function-name $FUNCTION_NAME
--runtime $RUNTIME
--role $ROLE
--handler $HANDLER
--region $REGION
--zip-file $ZIP_FILE
--profile $PROFILE
--environment $env_variables)
All the variables come from command line. It is failing for env_variables. This gets constructed as -
env_variables="Variables=INPUT=$DAYS"
where DAYS is actually "20 days"
How can I avoid this space and pass my command successfully.
shell-script shell quoting
marked as duplicate by Gilles
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 4 '17 at 18:50
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.
4
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
I need a string likeenv_variables="Variables=INPUT=20 days"
which means"Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.
â Aniket Thakur
Nov 4 '17 at 13:55
1
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Why does my shell script choke on whitespace or other special characters?
4 answers
I am trying to run aws create lambda function. It goes as follows -
eval $(aws lambda create-function
--function-name $FUNCTION_NAME
--runtime $RUNTIME
--role $ROLE
--handler $HANDLER
--region $REGION
--zip-file $ZIP_FILE
--profile $PROFILE
--environment $env_variables)
All the variables come from command line. It is failing for env_variables. This gets constructed as -
env_variables="Variables=INPUT=$DAYS"
where DAYS is actually "20 days"
How can I avoid this space and pass my command successfully.
shell-script shell quoting
This question already has an answer here:
Why does my shell script choke on whitespace or other special characters?
4 answers
I am trying to run aws create lambda function. It goes as follows -
eval $(aws lambda create-function
--function-name $FUNCTION_NAME
--runtime $RUNTIME
--role $ROLE
--handler $HANDLER
--region $REGION
--zip-file $ZIP_FILE
--profile $PROFILE
--environment $env_variables)
All the variables come from command line. It is failing for env_variables. This gets constructed as -
env_variables="Variables=INPUT=$DAYS"
where DAYS is actually "20 days"
How can I avoid this space and pass my command successfully.
This question already has an answer here:
Why does my shell script choke on whitespace or other special characters?
4 answers
shell-script shell quoting
edited Nov 4 '17 at 18:50
Gilles
507k12010031532
507k12010031532
asked Nov 4 '17 at 13:45
Aniket Thakur
243111
243111
marked as duplicate by Gilles
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 4 '17 at 18:50
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 Gilles
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 4 '17 at 18:50
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.
4
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
I need a string likeenv_variables="Variables=INPUT=20 days"
which means"Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.
â Aniket Thakur
Nov 4 '17 at 13:55
1
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39
add a comment |Â
4
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
I need a string likeenv_variables="Variables=INPUT=20 days"
which means"Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.
â Aniket Thakur
Nov 4 '17 at 13:55
1
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39
4
4
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
I need a string like
env_variables="Variables=INPUT=20 days"
which means "Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.â Aniket Thakur
Nov 4 '17 at 13:55
I need a string like
env_variables="Variables=INPUT=20 days"
which means "Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.â Aniket Thakur
Nov 4 '17 at 13:55
1
1
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Finally following worked -
env_variables=""Variables":"INPUT":"$DAYS""
lambda_create_command="aws lambda create-function --function-name $FUNCTION_NAME --runtime $RUNTIME --role $ROLE --handler $HANDLER --region $REGION --zip-file $ZIP_FILE --profile $PROFILE --environment '$env_variables'"
echo "Executing command : $lambda_create_command"
eval $lambda_create_command
Important points -
- Quotes in
env_variables
- Use of
eval
- Single quote in command string i.e
$env_variables
Reference - https://gist.github.com/andywirv/f312d561c9702522f6d4ede1fe2750bd
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Finally following worked -
env_variables=""Variables":"INPUT":"$DAYS""
lambda_create_command="aws lambda create-function --function-name $FUNCTION_NAME --runtime $RUNTIME --role $ROLE --handler $HANDLER --region $REGION --zip-file $ZIP_FILE --profile $PROFILE --environment '$env_variables'"
echo "Executing command : $lambda_create_command"
eval $lambda_create_command
Important points -
- Quotes in
env_variables
- Use of
eval
- Single quote in command string i.e
$env_variables
Reference - https://gist.github.com/andywirv/f312d561c9702522f6d4ede1fe2750bd
add a comment |Â
up vote
0
down vote
Finally following worked -
env_variables=""Variables":"INPUT":"$DAYS""
lambda_create_command="aws lambda create-function --function-name $FUNCTION_NAME --runtime $RUNTIME --role $ROLE --handler $HANDLER --region $REGION --zip-file $ZIP_FILE --profile $PROFILE --environment '$env_variables'"
echo "Executing command : $lambda_create_command"
eval $lambda_create_command
Important points -
- Quotes in
env_variables
- Use of
eval
- Single quote in command string i.e
$env_variables
Reference - https://gist.github.com/andywirv/f312d561c9702522f6d4ede1fe2750bd
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Finally following worked -
env_variables=""Variables":"INPUT":"$DAYS""
lambda_create_command="aws lambda create-function --function-name $FUNCTION_NAME --runtime $RUNTIME --role $ROLE --handler $HANDLER --region $REGION --zip-file $ZIP_FILE --profile $PROFILE --environment '$env_variables'"
echo "Executing command : $lambda_create_command"
eval $lambda_create_command
Important points -
- Quotes in
env_variables
- Use of
eval
- Single quote in command string i.e
$env_variables
Reference - https://gist.github.com/andywirv/f312d561c9702522f6d4ede1fe2750bd
Finally following worked -
env_variables=""Variables":"INPUT":"$DAYS""
lambda_create_command="aws lambda create-function --function-name $FUNCTION_NAME --runtime $RUNTIME --role $ROLE --handler $HANDLER --region $REGION --zip-file $ZIP_FILE --profile $PROFILE --environment '$env_variables'"
echo "Executing command : $lambda_create_command"
eval $lambda_create_command
Important points -
- Quotes in
env_variables
- Use of
eval
- Single quote in command string i.e
$env_variables
Reference - https://gist.github.com/andywirv/f312d561c9702522f6d4ede1fe2750bd
answered Nov 4 '17 at 14:38
Aniket Thakur
243111
243111
add a comment |Â
add a comment |Â
4
Did you try proper quoting?
â Ignacio Vazquez-Abrams
Nov 4 '17 at 13:46
I need a string like
env_variables="Variables=INPUT=20 days"
which means"Variables=INPUT=20 days"
is a json sting fed to environment option of the command. I tried DAYS="'45 days'". Does not work.â Aniket Thakur
Nov 4 '17 at 13:55
1
Please put that update ^^ ^^ ^^ into your question, where it belongs so that everyone can easily find it.
â roaima
Nov 4 '17 at 14:32
I guess it was quotes after all. Took couple of hour to figure correct combinations.
â Aniket Thakur
Nov 4 '17 at 14:39