Bash Script Run via Maven Does Not Promt for Input Properly












1















I have a bash script in which I am cloning a total of 5 repositories from a private server. I don't want the user to enter his credentials again and again, hence I prompt for them once and then reuse them.



This is my code for credentials promt



read -p "Enter Username: " username 
echo -n "Enter Password: "
read -s password


However when this piece of code is run via maven, it does not display the prompt messages such as Enter Username and does not even accept the -s silent input flag.
If run without maven, this script runs fine.



The catch is that if I use the read command without any flags or string prompts, it runs fine, which makes me think that maven might not be either recognizing or accepting these flags.



Has anyone else come across this?
I have tried using the interactive mode in maven as well, same results.










share|improve this question

























  • Why would you want to clone a repository like this?

    – Essex Boy
    Nov 22 '18 at 14:02











  • Use either a git credentials manager or ssh. They solve the same problems in a standard way

    – Mark Adelsberger
    Nov 22 '18 at 14:40











  • Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

    – phd
    Nov 22 '18 at 20:44











  • stackoverflow.com/search?q=%5Bgit%5D+skip+password

    – phd
    Nov 22 '18 at 20:44











  • Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

    – m_nazir
    Nov 23 '18 at 4:27
















1















I have a bash script in which I am cloning a total of 5 repositories from a private server. I don't want the user to enter his credentials again and again, hence I prompt for them once and then reuse them.



This is my code for credentials promt



read -p "Enter Username: " username 
echo -n "Enter Password: "
read -s password


However when this piece of code is run via maven, it does not display the prompt messages such as Enter Username and does not even accept the -s silent input flag.
If run without maven, this script runs fine.



The catch is that if I use the read command without any flags or string prompts, it runs fine, which makes me think that maven might not be either recognizing or accepting these flags.



Has anyone else come across this?
I have tried using the interactive mode in maven as well, same results.










share|improve this question

























  • Why would you want to clone a repository like this?

    – Essex Boy
    Nov 22 '18 at 14:02











  • Use either a git credentials manager or ssh. They solve the same problems in a standard way

    – Mark Adelsberger
    Nov 22 '18 at 14:40











  • Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

    – phd
    Nov 22 '18 at 20:44











  • stackoverflow.com/search?q=%5Bgit%5D+skip+password

    – phd
    Nov 22 '18 at 20:44











  • Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

    – m_nazir
    Nov 23 '18 at 4:27














1












1








1








I have a bash script in which I am cloning a total of 5 repositories from a private server. I don't want the user to enter his credentials again and again, hence I prompt for them once and then reuse them.



This is my code for credentials promt



read -p "Enter Username: " username 
echo -n "Enter Password: "
read -s password


However when this piece of code is run via maven, it does not display the prompt messages such as Enter Username and does not even accept the -s silent input flag.
If run without maven, this script runs fine.



The catch is that if I use the read command without any flags or string prompts, it runs fine, which makes me think that maven might not be either recognizing or accepting these flags.



Has anyone else come across this?
I have tried using the interactive mode in maven as well, same results.










share|improve this question
















I have a bash script in which I am cloning a total of 5 repositories from a private server. I don't want the user to enter his credentials again and again, hence I prompt for them once and then reuse them.



This is my code for credentials promt



read -p "Enter Username: " username 
echo -n "Enter Password: "
read -s password


However when this piece of code is run via maven, it does not display the prompt messages such as Enter Username and does not even accept the -s silent input flag.
If run without maven, this script runs fine.



The catch is that if I use the read command without any flags or string prompts, it runs fine, which makes me think that maven might not be either recognizing or accepting these flags.



Has anyone else come across this?
I have tried using the interactive mode in maven as well, same results.







bash git maven maven-plugin git-bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 0:02









madhead

14.9k1388126




14.9k1388126










asked Nov 22 '18 at 13:30









m_nazirm_nazir

164




164













  • Why would you want to clone a repository like this?

    – Essex Boy
    Nov 22 '18 at 14:02











  • Use either a git credentials manager or ssh. They solve the same problems in a standard way

    – Mark Adelsberger
    Nov 22 '18 at 14:40











  • Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

    – phd
    Nov 22 '18 at 20:44











  • stackoverflow.com/search?q=%5Bgit%5D+skip+password

    – phd
    Nov 22 '18 at 20:44











  • Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

    – m_nazir
    Nov 23 '18 at 4:27



















  • Why would you want to clone a repository like this?

    – Essex Boy
    Nov 22 '18 at 14:02











  • Use either a git credentials manager or ssh. They solve the same problems in a standard way

    – Mark Adelsberger
    Nov 22 '18 at 14:40











  • Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

    – phd
    Nov 22 '18 at 20:44











  • stackoverflow.com/search?q=%5Bgit%5D+skip+password

    – phd
    Nov 22 '18 at 20:44











  • Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

    – m_nazir
    Nov 23 '18 at 4:27

















Why would you want to clone a repository like this?

– Essex Boy
Nov 22 '18 at 14:02





Why would you want to clone a repository like this?

– Essex Boy
Nov 22 '18 at 14:02













Use either a git credentials manager or ssh. They solve the same problems in a standard way

– Mark Adelsberger
Nov 22 '18 at 14:40





Use either a git credentials manager or ssh. They solve the same problems in a standard way

– Mark Adelsberger
Nov 22 '18 at 14:40













Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

– phd
Nov 22 '18 at 20:44





Possible duplicate of Is there a way to skip password typing when using https:// on GitHub?

– phd
Nov 22 '18 at 20:44













stackoverflow.com/search?q=%5Bgit%5D+skip+password

– phd
Nov 22 '18 at 20:44





stackoverflow.com/search?q=%5Bgit%5D+skip+password

– phd
Nov 22 '18 at 20:44













Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

– m_nazir
Nov 23 '18 at 4:27





Can't use SSH as there are multiple users who clone these repositories as well. Can't keep adding new keys all the time.

– m_nazir
Nov 23 '18 at 4:27












1 Answer
1






active

oldest

votes


















1














Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:



pom.xml



<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>


bash



export PASSWORD=s3cr3t mvn task -Dsysprop.user=root


Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here






share|improve this answer
























  • I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

    – m_nazir
    Nov 23 '18 at 5:05











  • It's not bash's fault.

    – madhead
    Nov 23 '18 at 6:21











  • yeah you're right, I ended up taking the script out of the maven anyway

    – m_nazir
    Nov 23 '18 at 10:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432104%2fbash-script-run-via-maven-does-not-promt-for-input-properly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:



pom.xml



<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>


bash



export PASSWORD=s3cr3t mvn task -Dsysprop.user=root


Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here






share|improve this answer
























  • I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

    – m_nazir
    Nov 23 '18 at 5:05











  • It's not bash's fault.

    – madhead
    Nov 23 '18 at 6:21











  • yeah you're right, I ended up taking the script out of the maven anyway

    – m_nazir
    Nov 23 '18 at 10:11
















1














Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:



pom.xml



<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>


bash



export PASSWORD=s3cr3t mvn task -Dsysprop.user=root


Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here






share|improve this answer
























  • I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

    – m_nazir
    Nov 23 '18 at 5:05











  • It's not bash's fault.

    – madhead
    Nov 23 '18 at 6:21











  • yeah you're right, I ended up taking the script out of the maven anyway

    – m_nazir
    Nov 23 '18 at 10:11














1












1








1







Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:



pom.xml



<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>


bash



export PASSWORD=s3cr3t mvn task -Dsysprop.user=root


Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here






share|improve this answer













Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:



pom.xml



<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>


bash



export PASSWORD=s3cr3t mvn task -Dsysprop.user=root


Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 0:02









madheadmadhead

14.9k1388126




14.9k1388126













  • I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

    – m_nazir
    Nov 23 '18 at 5:05











  • It's not bash's fault.

    – madhead
    Nov 23 '18 at 6:21











  • yeah you're right, I ended up taking the script out of the maven anyway

    – m_nazir
    Nov 23 '18 at 10:11



















  • I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

    – m_nazir
    Nov 23 '18 at 5:05











  • It's not bash's fault.

    – madhead
    Nov 23 '18 at 6:21











  • yeah you're right, I ended up taking the script out of the maven anyway

    – m_nazir
    Nov 23 '18 at 10:11

















I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

– m_nazir
Nov 23 '18 at 5:05





I read your links, so it is possible that the behavior of bash might vary depending on whose calling it?

– m_nazir
Nov 23 '18 at 5:05













It's not bash's fault.

– madhead
Nov 23 '18 at 6:21





It's not bash's fault.

– madhead
Nov 23 '18 at 6:21













yeah you're right, I ended up taking the script out of the maven anyway

– m_nazir
Nov 23 '18 at 10:11





yeah you're right, I ended up taking the script out of the maven anyway

– m_nazir
Nov 23 '18 at 10:11




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432104%2fbash-script-run-via-maven-does-not-promt-for-input-properly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini