LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-16-2003, 04:00 PM   #1
pawellt
LQ Newbie
 
Registered: Dec 2003
Posts: 1

Rep: Reputation: 0
Simple script in Xdialog.. help


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
 
Old 12-17-2003, 01:41 AM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Here is an example:
Code:
#!/bin/bash
#Fall back to whiptail or dialog if Xdialog is missing or no X is available
DIALOG=dialog
[ -x "`which whiptail`" ] && DIALOG=whiptail
[ -n "$DISPLAY" ] && [ -x `which Xdialog` ] && DIALOG='Xdialog'

#Fail if still no dialog
[ -x "`which $DIALOG`" ] || ! echo 'No proper dialog found' || exit 1 


values=`$DIALOG --backtitle "This is the \"my eraser\"" \
--checklist "Eraser" 10 45 3 \
"a" "Erase tmp in home directory" OFF \
"b" "Erase xmule files" ON \
"c" "Erase /tmp" ON 2>&1 1>/dev/tty | tr '/"' '  '`

for value in `eval echo $values`; do 
  case $value in
    a)
      echo "I was going to erase tmp in my home directory"
    ;;
    b)
      echo "I wanted to erase xmule files.."
    ;;
    c)
      echo "I was going to erase /tmp.."
      ls /tmp
      echo "but instead listed contents of /tmp because this is just a demonstration"
    ;;
    *)
      echo "Unknown command '$value'"
    ;;
  esac
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Need help with Xdialog justintime32 Linux - Software 1 06-17-2005 02:17 PM
Using Xdialog to su death_au Linux - Newbie 1 05-31-2005 10:41 PM
Xdialog --progress bendeco13 Linux - General 0 10-27-2004 08:58 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 01:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration