non interactive input to interactive bash command failing

Viewed 31

Hi the following bash command works on my terminal in mac but fails when run on the terminal in docker:

#!/bin/sh
{ echo "ar"; sleep 1; echo "br"; } | ./4icli configure

Please enter your API Client ID:
Please enter your API Client Secret:
Validating credentials...
An error occurred validating these credentials. Request failed with status code 400

This same command fails on the docker terminal with the following error:

Please enter your API Client ID: sh: 1: read: Illegal option -s

Very puzzled how to get around this issue.

1 Answers
sh: 1: read: Illegal option -s

In bash, -s is silent mode for read. But often docker does not ship with bash as the default shell.

The solution depends the distribution behind the docker container and whether you can make sh be bash or whether you have to alter the script

Related