Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-16-2003, 04:00 PM   #1
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:


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

Rep: Reputation: 47
Here is an example:
#Fall back to whiptail or dialog if Xdialog is missing or no X is available
[ -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
      echo "I was going to erase tmp in my home directory"
      echo "I wanted to erase xmule files.."
      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'"


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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:06 PM.

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