LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-19-2006, 07:57 AM   #1
wintersa
LQ Newbie
 
Registered: Aug 2005
Distribution: Gentoo, Slackware
Posts: 9

Rep: Reputation: 0
Xdialog inputbox to make directorys


Hello,

Can someone post a sample of a bash script
to make directories with a Xdialog inputbox.

I have the following:


#!/bin/bash
Xdialog -default-no --ok-label "Continue" --cancel-label "Quit" --yesno \
"Directorys aanmaken" 0 0

if [ $? != "0" ] ; then
Xdialog --msgbox "Goodbye." 0 0
elif ; then
Xdialog --stdout -inputbox "Make a new directory?" 0 0 /bin/mkdir
fi


Thanks, Kind regards

Anthony
 
Old 12-19-2006, 08:50 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,140
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
You already used the exit status of the first Xdialog command to determine the next line of action, do the same for each next Xdialog use. And you got your "if" statement wrong. It's
Code:
if test; then 
 dosomething
else
 dosomethingelse
fi
Since you only need the exit value here you could use a case statement instead:
Code:
case "$?" in 
 0) dosomething;;
 *) dosomethingelse;; 
esac
Minor nit: don't use non-descriptive messages like "Goodbye", say something along the lines of "You choose not to make the directory" or leave out the message if it's going to confuse endusers.


Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.tldp.org/LDP/abs/html/"; }
 
Old 12-19-2006, 09:11 AM   #3
wintersa
LQ Newbie
 
Registered: Aug 2005
Distribution: Gentoo, Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Hello unSpawn,

Thanks for your fast reply, the script i wrote is not for
end-users it was a sample. I made it very quick without
thinking about the messages.

I`m not a programmer and I already read the tutorials on tldp.org.
And about the exit status,theres nothing wrong with it because it
is only used if you click on the button quit. (so with other words it must exit)

The only thing what i don`t understand is how do you make a directory from
the values you filled in the inputbox. how can you set these values to a
variable? If i know that than i can finische the script.

Kind Regards,

Anthony
 
Old 12-19-2006, 12:44 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,140
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
It's on stderr: dir=`gdialog --inputbox "Which dir?" 1 1 2>&1`
 
Old 12-19-2006, 02:15 PM   #5
wintersa
LQ Newbie
 
Registered: Aug 2005
Distribution: Gentoo, Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Thanksss unSpawn

It's done and I followed your advice and made a new
script, everything is working!!!

(and I must say the script looks now professional!!)


Thank you again.

Kind Regard

Anthony
 
Old 12-20-2006, 06:45 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,140
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
I`m not a programmer (..) I must say the script looks now professional!
See what shell scripting can do for your mana ;-p
 
  


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
Xdialog checklist help serris Programming 2 10-31-2006 02:57 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
bash scripting: dialog --inputbox chibiace Linux - Newbie 1 11-08-2004 10:22 PM
I can't make files in directorys Rangerjim Linux - Newbie 2 08-03-2004 03:28 PM


All times are GMT -5. The time now is 01:45 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