Title: fail on git password challenge during cronjob bash script
Tags: git;bash;cron;ubuntu-14.04
Question: I am running the following bash script as a cron job:
#!/bin/bash
gh[1]="https://github.com/myteam/myrepo1"
gh[2]="https://github.com/myteam/myrepo2"
gh[3]="https://github.com/myteam/myrepo3"
for index in ${!gh[*]}
do
git clone ${gh[$index]} ./src
done
some of the repos do not exist OR are password protected.  I have looked at a few options:
a. upgrade git to make use of new git features - GIT_TERMINAL_PROMPT: it is hard to upgrade git in Ubuntu 14.04, and if I can avoid it, it would be much better as I want my server to be "standard" (see https://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials)
b. change https to ssh (e.g. git://) - I can not do this either as I am getting a third-party list of https git locations
c. use the 'yes' command in Ubuntu e.g.
yes | git clone ....
this does not seem to work
d. pass random strings to the git clone command
echo " " | git clone
this does not seem to work either
Basically, what I would like to achieve is that if the git clone command is challenged for a password then it just fails and continues to the next ...
Comment: Ok - that looks really promising, but I probably lack the skills to really understand that.  I also want to continue rather than exist the script altogether.... I will have another look and play to see if I can come up with something.... THANK YOU THANK YOU SO MUCH!

Comment: did you look at `expect`? http://stackoverflow.com/questions/11204070/fail-if-a-script-expects-input-or-entering-passwords



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:03/27/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<git><bash><cron><ubuntu-14.04>', 'Title': 'fail on git password challenge during cronjob bash script', 'ViewCount': 46, 'id': 43057661, 'user_AboutMe': '', 'user_AccountId': 9781785.0, 'user_DisplayName': 'Nicolaas Thiemen Francken', 'user_Reputation': 181.0, 'user_Views': 48.0, 'user_id': 7249528.0}}