Home Bash: Gathering all inputs at once, without waiting for the process to end
Reply: 0

Bash: Gathering all inputs at once, without waiting for the process to end

user1202
1#
user1202 Published in May 24, 2018, 4:00 pm

I have been writing a bash script in which the process depends on the user's input, but it is a 1min process, and if the user wants to do it more than once, he will have to wait for the loop to finish. Here is the code:

while [[ ! "$addstr" =~ ^[Nn](.*)?$ ]]; do
    read -p "[*] String to permute around: " string
    echo; sleep 0.1s

    while [[ ! "$string" =~ ^[0-9a-zA-Z]+$ ]]; do
        echo "[!] Only alphanumeric strings are allowed!"; sleep 0.1s
        read -p "=> " string
        echo; sleep 0.1s
    done

    ## PROCESS ##

    echo "[?] Do you want to permute around another string?"; sleep 0.1s
    read -p "=> " addstr
    echo; sleep 0.1s

    while [[ ! "$addstr" =~ ^[YyNn](.*)?$ ]]; do
        echo "[!] Type again:"
        read -p "=> " addstr
        echo; sleep 0.1s
    done
done

What i want to do is to allow the user to enter all strings AT ONCE, storing the variables for each of them and running the process as many times as it needs... I tryed a lot of things, even appending a "$counter" after "$string" but couldn't make this work, i believe it's something very simple and i just don't have the knowledge..

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.446419 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO