0

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:

#!/bin/bash passDir="/etc/passwd" while true do #propmt for username read -p "Enter username : " username egrep "^$username" $passDir >/dev/null if [ $? -eq 0 ]; then echo "$username exists!" else userName=$username break fi done 

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.

0

    1 Answer 1

    1

    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.

    1
    • 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
      CommentedSep 14, 2014 at 12:39

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.