0

Follow the below script I've a unique variable that keeps all variables, I need have each variable separated from $VALUES:

#!/bin/bash
shell=""
groups=""
user=""
home=""
exec 3>&1
VALUES=$(dialog --ok-label "Submit" \
          --backtitle "Linux User Managment" \
          --title "Useradd" \
          --form "Create a new user" \
15 50 0 \
        "Username:" 1 1 "$user"         1 10 10 0 \
        "Shell:"    2 1 "$shell"        2 10 15 0 \
        "Group:"    3 1 "$groups"       3 10 8 0 \
        "HOME:"     4 1 "$home"         4 10 40 0 \
2>&1 1>&3)
exec 3>&-

echo "$VALUES"

1 Answer 1

5

That worked for me:

#!/bin/bash
shell=""
groups=""
user=""
home=""
exec 3>&1
dialog --separate-widget $'\n' --ok-label "Submit" \
          --backtitle "Linux User Managment" \
          --title "Useradd" \
          --form "Create a new user" \
15 50 0 \
        "Username:" 1 1 "$user"         1 10 10 0 \
        "Shell:"    2 1 "$shell"        2 10 15 0 \
        "Group:"    3 1 "$groups"       3 10 8 0 \
        "HOME:"     4 1 "$home"         4 10 40 0 \
2>&1 1>&3 | {
  read -r user
  read -r shell
  read -r groups
  read -r home

  echo $user
  echo $shell
  echo $groups
  echo $home

  #continue script here
}
exec 3>&-
1
  • Thanks for your reply. Do you know how I can control "return" key of keyboard so when I press it, cursor goes to next line? Commented Jul 25, 2014 at 13:03

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.