-1

I am very new to writing Shell scripts and am trying to write a simple script to run Vagrant up then SSH into the box and run some commands. The echo Hi there will run but the read -p will never show. Am I doing this wrong or is there a work around of some sort?

vagrant ssh default << 'ENDSSH'
read -p "Enter your first name:" FIRST_NAME
echo Hi there
ENDSSH
0

Inside if a heredoc you can substitute variables, but it won't run any commands unless you put them in command substitution ($()). Put your read before the vagrant and use the resulting variable in your heredoc.

  • Thank you for the response! Would you happen to know another work around though? This is a basic example, but I want to call another script within the ENDSSH which has read in it but won't run inside there (the method you recommended just won't be applicable to my scenario). Any help is much appreciated. – Kevin Nov 19 '18 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.