I know there is many similar questions but I was not able to find an answer for mine:

I have couple of if and checking to get to this point of source script to call another script

source ./call.sh

And in destination script I want to get user name from user:

while true
        #propmt for username
        read -p "Enter username : " username
        egrep "^$username" $passDir >/dev/null
        if [ $? -eq 0 ]; then
            echo "$username exists!"


But it doesn't wait for me to enter anything. It goes inside a loop and print exist unless I press Ctrl+C I appreciate if anyone can give me suggestion how to do it. In my destination script I have dozen of other prompts to get input from the user When I run destination script alone it works fine.


You have to write a extra script and call with source command and interactive with your script, You have to use expect interpreter such as:

#!/usr/bin/env expect 
send 'username\r'

Sure, you need to pass somthing to your script and use its return status.

  • Thanks for your answer. I am very mobtadi in bash script. So I need to create another script. So from source I call this script and this script call destination script. Could you please just write a very simple one so I can use it. – Bernard Sep 14 '14 at 12:39

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.