LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-27-2017, 10:59 AM   #1
ArneVanP
LQ Newbie
 
Registered: Dec 2017
Posts: 5

Rep: Reputation: Disabled
Dialog -returning to a previous dialog


Hello,

I am writing a bash script to vieuw some computer architecture specs of my pc, i have succesfully created a first dialog menu box that displays my options that i want to display, but one if the options is to vieuw the memory, i wanted to split this option into two sub-options, RAM and ROM so when the memory option is selected i open up a new menu dialog where the user can chose between RAM and ROM, now i wondered if there is the possibilety to let the cancel label return you to the previous menu box.

Already a big thanks in advance
 
Old 12-27-2017, 11:12 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
Quote:
Originally Posted by ArneVanP View Post
Hello,

I am writing a bash script to vieuw some computer architecture specs of my pc, i have succesfully created a first dialog menu box that displays my options that i want to display, but one if the options is to vieuw the memory, i wanted to split this option into two sub-options, RAM and ROM so when the memory option is selected i open up a new menu dialog where the user can chose between RAM and ROM, now i wondered if there is the possibilety to let the cancel label return you to the previous menu box.

Already a big thanks in advance
So why not post your script ?

Ask yourself; How are we going to advise you about it, if we cannot see it?

Please use CODE tags when you do...
 
1 members found this post helpful.
Old 12-27-2017, 11:31 AM   #3
ArneVanP
LQ Newbie
 
Registered: Dec 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jsbjsb001 View Post
So why not post your script ?

Ask yourself; How are we going to advise you about it, if we cannot see it?

Please use CODE tags when you do...
I am sorry, new to forums..
the code is not yet completed-
don't mind all the text.
so as you can see i've created a menu box in the first highlights and one in the second highlights, from the second menu box when the cancel button is presses I would like it to re-open the first menu dialog. is this possible?
Code:
#!/bin/bash

# de opmaak van de dialog boxen, (14-18)
# (24-29) heb ik van de site linuxcommand.org
# het gebruiken van command substitutie en command omleiding heb ik opgezocht op het internet
# hoe deze werken en wat ze doen, ze vermijden het gebruiken van tijdelijke bestanden
# zodat het programma een beetje overzichtelijker is :)

cansel_toets=1
escape_toets=255
HEIGHT=0
WIDTH=0

toon_uitkomst() {
   dialog --title "$1" \
    --no-collapse \
    --ok-label "keer terug" \
    --msgbox "$uitkomst" 0 0
}

while true; do
 exec 3>&1
 selectie1=$(dialog \
   --backtitle "Computer Architectuur" \
   --title "Menu" \
   --clear \
   --cancel-label "Exit" \
   --menu "Kies 1 van volgende opties: \n (gebruikt UP en DOWN voor keuze ENTER voor te kiezen)" $HEIGHT $WIDTH 4 \
   "1" "Toon Proccesoren en cores" \
   "2" "Toon geheugen" \
   "3" "Toon aangesloten schijven en USB poorten" \
   "4" "Toon huidige belasting" \
   2>&1 1>&3)
 exit_status=$?
 exec 3>&-
 case $exit_status in
   $cansel_toets)
     clear 
     echo "Script is beŽindigt"
     exit
     ;;
   $escape_toets)
     clear
     echo " Programma gesopt" >&2
     exit 1
     ;;
 esac
 case $selectie1 in
   0 )
      clear
      echo "Script is beŽindigt"
      ;;
   1 )
     uitkomst=$(lscpu)
     toon_uitkomst "Proccesoren en cores :"
     ;;
   2 )
     clear
     exec 3>&1
     selectie2=$(dialog \
     --backtitle "Computer Architectuur" \
     --title "Geheugen" \
     --clear \
     --cancel-label "keer terug" \
     --menu "Kies voor RAM(1) of ROM(2):" $HEIGHT $WIDTH 4 \
     "1" "Toon RAM geheugen" \
     "2" "Toon ROM geheugen" \
     2>&1 1<&3)
     exit_status2=$?
     exec 3>&-
       case $exit_status2 in
         $cansel_toets )
	   clear
	   echo "Script is beŽindigt"
	   exit
	   ;;
	 $escape_toets )
	   ;;
	 esac
	 case $selectie2 in
	   0 )
	     clear
	     echo "Script is beŽindigt"
	     ;;
	   1 )
	     result=$(
 
Old 12-27-2017, 09:23 PM   #4
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
To be honest, I was hoping that others would have chimed in by now, given that my scripting skills ain't what I'd call advanced. Some of it makes sense to me... some of it really doesn't.

But I was thinking that if you could "loop" it so that it returns back to the previous dialog, then I'm thinking the answer would have to be yes.

I did find something for you to look at (and maybe I might have a closer look at scripting one day myself), anyway's here it is: https://books.google.com.au/books?id...nd.org&f=false

Well, best of luck with it and maybe wait for some more knowledgeable scripters to reply. And let us know how you go.
 
1 members found this post helpful.
Old 12-28-2017, 03:45 AM   #5
ArneVanP
LQ Newbie
 
Registered: Dec 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Well I got it to work a bit like I intended, thank you for you're time.
Here is my working script :
PS : if anyone sees someting I could have done more efficient please let my know
Code:
#!/bin/bash

# de opmaak van de dialog boxen, (14-18)
# (24-29) heb ik van de site linuxcommand.org
# het gebruiken van command substitutie en command omleiding heb ik opgezocht op het internet
# hoe deze werken en wat ze doen, ze vermijden het gebruiken van tijdelijke bestanden
# zodat het programma een beetje overzichtelijker is :)

cansel_toets=1
escape_toets=255
HEIGHT=0
WIDTH=0

toon_uitkomst() {
   dialog --title "$1" \
    --no-collapse \
    --ok-label "keer terug" \
    --msgbox "$uitkomst" 0 0
}

while true; do
 exec 3>&1
 selectie1=$(dialog \
   --backtitle "Computer Architectuur" \
   --title "Menu" \
   --clear \
   --cancel-label "Exit" \
   --menu "Kies 1 van volgende opties: \n (gebruikt UP en DOWN voor keuze ENTER voor te kiezen)" $HEIGHT $WIDTH 4 \
   "1" "Toon Proccesoren en cores" \
   "2" "Toon geheugen" \
   "3" "Toon USB-poorten" \
   "4" "Toon huidige belasting" \
   2>&1 1>&3)
 exit_status=$?
 exec 3>&-
 case $exit_status in
   $cansel_toets)
     clear 
     echo "Script is beŽindigt"
     exit
     ;;
   $escape_toets)
     clear
     echo " Programma gesopt" >&2
     exit 1
     ;;
 esac
 case $selectie1 in
   0 )
      clear
      echo "Script is beŽindigt"
      ;;
   1 )
     uitkomst=$(lscpu)
     toon_uitkomst "Proccesoren en cores :"
     ;;
   2 )
     exec 3>&1
     selectie2=$(dialog \
     --backtitle "Computer Architectuur" \
     --title "Geheugen" \
     --clear \
     --cancel-label "keer terug" \
     --menu "Kies voor RAM(1) of ROM(2):" $HEIGHT $WIDTH 4 \
     "1" "Toon harde schijf info" \
     "2" "Toon RAM geheugen" \
     2>&1 1<&3)
     exit_status2=$?
     exec 3>&-
       case $exit_status2 in
         $cansel_toets )
	   clear
	   echo "Script is beŽindigt"
	   exit
	   ;;
	 $escape_toets )
	   ;;
	 esac
	 case $selectie2 in
	   0 )
	     clear
	     echo "Script is beŽindigt"
	     ;;
	   1 )
	     uitkomst=$(lsblk)
	     toon_uitkomst "Harde schijven :"
	     ;;
	   2 )
	     uitkomst=$(free -m)
             toon_uitkomst "RAM in MB :"
	     ;;
          esac
        ;;
      3 )
        uitkomst=$(lsusb)
	toon_uitkomst "Aangesloten USB-poorten :"
	;;
      4 )
        uitkomst=$(uptime)
	toon_uitkomst "uptime van de server"
	;;
   esac
done
 
1 members found this post helpful.
Old 12-28-2017, 04:10 AM   #6
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
Well done ArneVanP!

Good work. I'm glad to hear you got it figured out, sorry I couldn't be of more help to you. My scripting skills I'd say are maybe somewhere between basic to intermediate.

Thanks for letting us know how it went for you. Hopefully the link I give you was of at least some use to you. You kind have me wanting to brush up on my scripting ability's now. (or lack of, to some extent)

Once again, great work!

Come back any time, if you have any more questions.
 
  


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
Reproducing Alt-F2 run dialog effect (focus dialog box, dim and disable rest of desktop) in LinuxMint Cinnamon in other applications. kevin77v Linux - Desktop 0 01-20-2016 01:44 PM
File keeps returning to previous prudens Linux - Newbie 13 08-10-2009 05:25 AM
Dialog cookie_ie Programming 5 04-11-2005 02:48 AM
dialog ziox Programming 1 03-16-2005 02:09 PM
Dialog phatbastard Linux - Security 3 12-13-2004 10:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:29 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration