Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-06-2010, 02:14 PM   #1
Registered: Dec 2006
Posts: 107

Rep: Reputation: 17
break: cannot break

hi guys

I am working on a menu for linux... some basic stuff.

but I have an issue. I got 1 server where something is working and the same thing does not work in the same way in another linux box

Basically I am simulating a command line where user insert some commands and to end and go back to the previous menu that person has to press Control + C and Enter Key

all my server are centos 5.0

I am adding my menu here

basically you execute ./menu

After that go to option

9. Opciones
7. Ejecutar comando
and execute a command like pwd
after that
Press Control + C and Enter Key

but I got error ./menu: break: cannot break
but in other servers pressing Control + C and Enter Key goes back to previous menu

any idea how to fix that?
or another way to exit from that simulated command line and go back to previous menu where I selected 7. Ejecutar comando

Basically this is the part that has issues

##Shell simulada para ejecutar commandos 
ejecutacmd ()
echo -e "${bold}Press Control+C and Enter Key to go back to previous menu${offbold}"
echo -e " "
while true ; do
     read whichcmd?"Enter Command: "
     if [ $(sudo -l | grep -c "$whichcmd") -gt 0 ] ; then
          sudo $whichcmd
menu (code) is attached so you can see all options
thanks a lot

Uploaded as menu.txt just remove .txt and test it
Attached Files
File Type: txt menu.txt (12.6 KB, 6 views)
Old 05-06-2010, 07:25 PM   #2
Registered: Dec 2006
Posts: 107

Original Poster
Rep: Reputation: 17
well guys I ended doing this

I don't know if it's the best way but that's the only thing that came to my mind

ejecutacmd ()
echo -e "Digite ${bold}end${offbold} para finalizar"
echo -e " "
while [ "$whichcmd" != end ]
     read whichcmd?"Enter Command: "


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
Break my coursework!! craigs1987 General 2 09-22-2006 07:49 AM
Possible Break In??? stlyz3 Linux - Security 9 10-26-2005 03:43 PM
How does it all break down? Bu3Nix Slackware - Installation 5 09-15-2005 03:50 PM
could I break my pc? linuxhippy Slackware 9 04-02-2005 08:15 AM
Could someone please break it down for me...? Pwcca Slackware 6 01-23-2003 11:05 AM

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