Re: [expert] menu in bash script
Thanks all for the help and direction. You are all very kind. Always glad to help! :-) The case why I asked for this help is that we have a project to install Linux servers on several locations with the same/very similar settings. Unfortunately, the hardware is varied between locations so 'ghosting hdd is not the solutions. I'm too about to write an auto-rescue-install for my own linux distro :-P Thanks again. Good luck! Artemio. Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
The case why I asked for this help is that we have a project to install Linux servers on several locations with the same/very similar settings. Unfortunately, the hardware is varied between locations so 'ghosting hdd is not the solutions. I wrote the following script to do something similar. It was used to install an embedded system with a canned set of packages. There are a couple other files associated with it that I've long lost, but it's easy enough to figure out. http://www.digitalhermit.com/~kwan/install_system -- The Digital Hermit Unix and Linux Solutions http://www.digitalhermit.com [EMAIL PROTECTED] Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
[expert] menu in bash script
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Thanks - -- Fajar http://linux.arinet.org Linux mdk91.sistek.kom 2.4.21-0.13mdk GNU/Linux 21:40:27 up 29 min, 10 users, load average: 1.24, 0.62, 0.46 Quote of the day: The package said requires Microsoft Windows 95 or better - I don't understand why it doesn't work on my pocket calculator! -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/tOopMai9kCFqACoRAtDWAKCy9RUiSWb0etqoi/YlcdV/Nm/hBACeMEEl Jo1pLp6ZHRCu9/scgqg3CDI= =oeuw -END PGP SIGNATURE- Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
Fajar Priyanto wrote: Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Thanks It's very easy with case operator. Here is the source (is is also attached - just save it, chmod +x menu.sh and launch it ./menu.sh): +++ #!/bin/bash #output a menu echo [menu] echo 1 do this echo 2 do that echo 3 etc #echo with no end-of-line echo -n selection: #read user input read action #do something depending on input stored in $action variable case $action in 1) echo you selected 1 #put action 1 here ;; 2) echo you selected 2 #put action 2 here ;; 3) echo you selected 3 #put action 3 here ;; *) echo you can select only 1, 2 or 3 #default action ;; esac #that's all echo bye +++ Hope this helps. Artemio. menu.sh Description: application/shellscript Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
Le Vendredi 14 Novembre 2003 15:43, Fajar Priyanto a écrit : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Thanks - -- Fajar http://linux.arinet.org Linux mdk91.sistek.kom 2.4.21-0.13mdk GNU/Linux 21:40:27 up 29 min, 10 users, load average: 1.24, 0.62, 0.46 Quote of the day: The package said requires Microsoft Windows 95 or better - I don't understand why it doesn't work on my pocket calculator! -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/tOopMai9kCFqACoRAtDWAKCy9RUiSWb0etqoi/YlcdV/Nm/hBACeMEEl Jo1pLp6ZHRCu9/scgqg3CDI= =oeuw -END PGP SIGNATURE- I don't have much time going in details. but under bash you could use select like select i in 'Copy /etc/dhcpd.conf' '2. Copy /etc/wvdial.conf' 'Make directory /var/log/nullmailer' 'Do all of above'; do echo $REPLY; done You could do a case on the $REPLY. Unfortunately this command keeps asking until you press Ctrl-D. Sorry not to have time to explain in more details (type help select), Clement. Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
Fajar Priyanto wrote: Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Besides the case operator that someone else has mentioned, you can also use the dialog utility to create menu boxes. For example: dialog --clear --backtitle A Checkbox --title Choose one: \ --menu Please select one item:\n 30 30 8 \ Item1 Choose me \ Item2 No, choose me \ Item3 Better choose me The selection will be sent to stderr which you can either capture to a file or read directly. You'll still need the case operator or nested ifs to act on the user choice. Dialog will also do text input, checkbox, radiobox, etc.. If dialog is cumbersome but you do like the interactivity, take a look at the newt package. It has some very easy ways of generating similar menus. -- The Digital Hermit Unix and Linux Solutions http://www.digitalhermit.com [EMAIL PROTECTED] Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
On Fri, 2003-11-14 at 10:46, Kwan Lowe wrote: Fajar Priyanto wrote: Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Besides the case operator that someone else has mentioned, you can also use the dialog utility to create menu boxes. For example: dialog --clear --backtitle A Checkbox --title Choose one: \ --menu Please select one item:\n 30 30 8 \ Item1 Choose me \ Item2 No, choose me \ Item3 Better choose me The selection will be sent to stderr which you can either capture to a file or read directly. You'll still need the case operator or nested ifs to act on the user choice. Dialog will also do text input, checkbox, radiobox, etc.. If dialog is cumbersome but you do like the interactivity, take a look at the newt package. It has some very easy ways of generating similar menus. but if you learn dialog, then you can readily port the same script to xdialog, which is keen :-) -- Jack Coates at Monkeynoodle Dot Org: It's A Scientific Venture... Come on you rambling boys of pleasure and ladies of easy leisure, we must say A dios until we see Almaria once again. -- Fiesta from If I Should Fall From Grace With God by The Pogues Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
but if you learn dialog, then you can readily port the same script to xdialog, which is keen :-) Yes -- xdialog has effectively replaced 90% of my tcl/tk needs. It's still not a complete substitute, but the ease of generating interfaces makes up for its inflexibility. -- The Digital Hermit Unix and Linux Solutions http://www.digitalhermit.com [EMAIL PROTECTED] Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
Am Freitag, 14. November 2003 20:13 schrieb Jack Coates: On Fri, 2003-11-14 at 10:46, Kwan Lowe wrote: Fajar Priyanto wrote: Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Besides the case operator that someone else has mentioned, you can also use the dialog utility to create menu boxes. For example: dialog --clear --backtitle A Checkbox --title Choose one: \ --menu Please select one item:\n 30 30 8 \ Item1 Choose me \ Item2 No, choose me \ Item3 Better choose me The selection will be sent to stderr which you can either capture to a file or read directly. You'll still need the case operator or nested ifs to act on the user choice. Dialog will also do text input, checkbox, radiobox, etc.. If dialog is cumbersome but you do like the interactivity, take a look at the newt package. It has some very easy ways of generating similar menus. but if you learn dialog, then you can readily port the same script to xdialog, which is keen :-) tried the above with gdialog. This is cool :D This is exactly why i love this list ;) Steffen Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
On Fri, 14 Nov 2003 21:43:50 +0700 Fajar Priyanto [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear All, Can we make menu in bash script just like in DOS' batch file? Such as: === [Menu] Pls select what you want to do: 1. Copy /etc/dhcpd.conf 2. Copy /etc/wvdial.conf 3. Make directory /var/log/nullmailer 4. Do all of above == Could you please give me some examples? Thanks - -- this script allows you to choose an action with arrow keys then select with enter or quit with Q replace the actions to do in the last case statement with what you want. bye jipe the script -- :) #!/bin/bash #menu.sh clear echo Please select an action echo menuA[1]=$(echo -e \e[1;34;46m-1-\e[0m\tCopy /etc/dhcpd.conf) menuB[1]=$(echo -e \e[1;34;47m-1-\e[0m\tCopy /etc/dhcpd.conf) menuA[2]=$(echo -e \e[1;34;46m-2-\e[0m\tCopy /etc/wvdial.conf) menuB[2]=$(echo -e \e[1;34;47m-2-\e[0m\tCopy /etc/wvdial.conf) menuA[3]=$(echo -e \e[1;34;46m-3-\e[0m\tMake directory /var/log/nullmailer) menuB[3]=$(echo -e \e[1;34;47m-3-\e[0m\tMake directory /var/log/nullmailer) menuA[4]=$(echo -e \e[1;34;46m-4-\e[0m\tDo all of above) menuB[4]=$(echo -e \e[1;34;47m-4-\e[0m\tDo all of above) echo ${menuA[1]} echo ${menuA[2]} echo ${menuA[3]} echo ${menuA[4]} action=1 V=1 v=1 echo -en \e[$((V+2));1H${menuB[V]} while ((action)); do read -s -n1 R1 case $R1 in $'\x1b') read -s -n1 R2 case $R2 in $'\x5b') read -s -n1 R3 case $R3 in $'\x41') ((V--)) ;; $'\x42') ((V++)) ;; *) continue ;; esac ;; *) continue ;; esac ;; [qQ]) clear; exit 63 ;; ) action=0 ;; *) continue ;; esac if [ $V = 0 ]; then V=4; fi if [ $V = 5 ]; then V=1; fi echo -en \e[$((v+2));1H${menuA[v]} echo -en \e[$((V+2));1H${menuB[V]} v=$V case $action in 0) clear case $V in 1) echo Copying /etc/dhcpd.conf ;; 2) echo Copying /etc/wvdial.conf ;; 3) echo Making directory /var/log/nullmailer ;; 4) echo Doing all of above ;; esac esac done exit 0 Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
[expert] Color with echo in shell script (was: [expert] menu in bash script)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, jipe wrote: snip menuA[1]=$(echo -e \e[1;34;46m-1-\e[0m\tCopy /etc/dhcpd.conf) I would like to get more details on how to display color in shell script and on terminal. I understand that 34 and 46 are the color. How does this actually work ? Are the color the same as the one in /etc/DIR_COLORS ? Can anybody point me the a good reference docuement. I did not find anything in the man pages. Thanks, Jean-Pierre Denis jp at msfree dot ca Public Key: http://www.msfree.ca/jp.asc -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/tUf8kIJ3t0MEaMsRAnxEAKC0iPr0HH5Xhjl4GcZVIOdlw49cTACgtgoF dghrrEQSIzYQZfA7Aqz5HeE= =gixM -END PGP SIGNATURE- Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Color with echo in shell script (was: [expert] menu in bash script)
On Fri, 14 Nov 2003 16:24:29 -0500 (EST) Jean-Pierre Denis [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, jipe wrote: snip menuA[1]=$(echo -e \e[1;34;46m-1-\e[0m\tCopy /etc/dhcpd.conf) I would like to get more details on how to display color in shell script and on terminal. I understand that 34 and 46 are the color. How does this actually work ? Are the color the same as the one in /etc/DIR_COLORS ? Can anybody point me the a good reference docuement. I did not find anything in the man pages. Thanks, Jean-Pierre Denis jp at msfree dot ca just have a look here: http://tldp.org/LDP/abs/html/colorizing.html bye jipe Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Color with echo in shell script (was: [expert] menu in bash script)
On Fri, 2003-11-14 at 18:06, jipe wrote: On Fri, 14 Nov 2003 16:24:29 -0500 (EST) Jean-Pierre Denis [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, jipe wrote: snip menuA[1]=$(echo -e \e[1;34;46m-1-\e[0m\tCopy /etc/dhcpd.conf) I would like to get more details on how to display color in shell script and on terminal. I understand that 34 and 46 are the color. How does this actually work ? Are the color the same as the one in /etc/DIR_COLORS ? Can anybody point me the a good reference docuement. I did not find anything in the man pages. Thanks, Jean-Pierre Denis jp at msfree dot ca just have a look here: http://tldp.org/LDP/abs/html/colorizing.html bye jipe Also take a look at: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Adolfo Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] menu in bash script
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Friday 14 November 2003 10:27 pm, Artemio wrote: It's very easy with case operator. Here is the source (is is also attached - just save it, chmod +x menu.sh and launch it ./menu.sh): Thanks all for the help and direction. You are all very kind. The case why I asked for this help is that we have a project to install Linux servers on several locations with the same/very similar settings. Unfortunately, the hardware is varied between locations so 'ghosting hdd is not the solutions. I have prepared all necessary conf files to be copied into those servers, so I thought an install script with menu would be speeding and convenient the installation process. Thanks again. - -- Fajar http://linux.arinet.org Linux mdk91.sistek.kom 2.4.21-0.13mdk GNU/Linux 08:35:40 up 1:00, 10 users, load average: 0.30, 0.15, 0.08 Quote of the day: Windows 98 is guaranteed to make your system 98% slower. -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/tYQxMai9kCFqACoRArgAAJkB3hnCJguRqJbHWtl8r33wMR5KwwCfeRDV bSSt6aT9xxJWgGkM8xe4ZKE= =ofrJ -END PGP SIGNATURE- Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com