0

I am creating automatic plugin update function using bash and wp cli command.Using bash script i have checking update available plugins and storing those plugin names in a text file. Now i want to update plugin one by one by reading the plugin name from text file i created. When reading plugin name from text file i want to display "Do you want to update ? Y/N " command on terminal. If user submit yes then update first plugin else show "Do you want to update ? Y/N " command for second plugin.

I have written code for that but its not working. Its not displaying "Do you want to update ? Y/N " on terminal. I added that code inside the while loop of bash script.

How can i display "Do you want to update ? Y/N " on terminal by using while loop in bash script ??? Then i want to update plugin based on user input is equal to Y. if user input is N then dont update that plugin.

Following are my code its not working now.

read -p "Do you want to list Plugin updates for $user ? Y/N " -n 1 -r
  echo
  if [[ $REPLY =~ ^[Yy]$ ]]
  then
    echo
    # Display the list of plugins
    wp plugin list --update=available
    wp plugin list --update=available --field=name > plugins.txt
    while read p; do
    read -p "Do you want Plugin updates for $p ? Y/N " -n 1 -r
        if [[ $REPLY =~ ^[Yy]$ ]]
            then
            echo
            wp plugin update $p
        fi
        done <plugins.txt
  fi
  echo "-----------------------------------------------------------"
echo "Finished!"
10
  • 1
    This question has nothing to do with PHP nor Wordpress. Remove these tags from it. Commented Aug 29, 2019 at 10:30
  • @adripanico thanks that was my mistake i removed that Commented Aug 29, 2019 at 10:31
  • @Inian How this will come under duplicate ? Commented Aug 29, 2019 at 10:37
  • See another duplicated - stackoverflow.com/questions/6883363/… Commented Aug 29, 2019 at 10:39
  • But those are different answer, I want to read file first then need to display that question on terminal based on answer need to update plugin Commented Aug 29, 2019 at 10:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.