Find the answer to your Linux question:
Results 1 to 2 of 2
Hello everybody, I need to write a simple script in xdialog. You select on checklist one option and this script call one command. I have at this moment: #!/bin/sh DIALOG=Xdialog ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2003
    Posts
    1

    simple script - selection options on checklist


    Hello everybody,

    I need to write a simple script in xdialog.
    You select on checklist one option and this script
    call one command. I have at this moment:

    #!/bin/sh
    DIALOG=Xdialog

    $DIALOG --backtitle "This is the \"my eraser\"" \
    --checklist "Eraser" 0 0 0 \

    "a" "Erase tmp in home directory" OFF \
    "b" "Erase xmule files" ON \
    "c" "Erase /tmp" ON\

    What should I do, that after selection of option "a", system will do
    "rm -fr /home/pawel/tmp/*".. after selection "b" - "rm -fr .xmule/tmp/*"
    etc ...

    Thanks for help,
    Pawel

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I have not used xdialog, but I guess that it works the same as the ncurses dialog. In that case, I would do that like this:
    Code:
    #!/bin/sh
    
    temp="$(dialog your arguments 2>&1)"
    eval "ans=($temp)"
    
    for cmd in "${ans[@]}"; do
        case "$cmd" in
        a)
            rm -rf /home/pawel/tmp/*
            ;;
        b)
            rm -rf ~/.xmule/tmp/*
            ;;
        (and so on)
    done

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •