Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: someone help me with a bit of bash?

  1. #11
    Join Date
    Mar 2009
    Location
    Buenos Aires, AR
    Beans
    2,325
    Distro
    Ubuntu

    Re: someone help me with a bit of bash?

    OMG use Gufw

  2. #12
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: someone help me with a bit of bash?

    You could ask it to pause or sleep, but it would be simpler to just use GUFW.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #13
    Join Date
    Apr 2008
    Location
    RiceMonsterland, Canada
    Beans
    Hidden!

    Re: someone help me with a bit of bash?

    Quote Originally Posted by andru183 View Post
    no but if they ask for status to see if its on or not i wanted the shell to show the status, i thought the shell wouldn't close till the user either pressed ctrl-z or enter, didnt know it required something to stay open while it showed the status
    With this code, it will keep going until they type "quit". If you want it to exit after any of the options, just add exit or break to said option.

    Code:
    #!/bin/bash
    
    echo 'Your chance to turn your fire wall on/off or check status
    ================================================== ========================
    
    Please type on/off or status'
    
    
    while true; do
    
    	read x
    
    	case "$x" in
    		on)
    			sudo ufw -enable
    		;;
    		off)
    			sudo ufw -disable	
    		;;
    		status)
    			sudo ufw -status
    		;;
    		quit)
    			echo "Bye!"
    			exit
    		;;
    		*)
    			echo "Invalid option"
    		;;
            esac
    
    done
    Last edited by RiceMonster; April 25th, 2010 at 05:51 PM.
    Code:
    while true; do echo -n "RiceMonster "; done
    Best thread ever

  4. #14
    Join Date
    Jun 2007
    Location
    The Mistake by the Lake
    Beans
    1,813

    Re: someone help me with a bit of bash?

    I don't get how Rice's sig works.
    Code:
    while true; do echo -n "RiceMonster "; done
    While what is true? How does the script run if there is no value that is true?
    Quote Originally Posted by Homer J. Simpson
    "Dinner is the perfect break between work, and drunk."


  5. #15
    Join Date
    Dec 2006
    Beans
    217

    Re: someone help me with a bit of bash?

    Quote Originally Posted by swoll1980 View Post
    I don't get how Rice's sig works.
    Code:
    while true; do echo -n "RiceMonster "; done
    While what is true? How does the script run if there is no value that is true?
    while true is true (i.e this is always going to happen) write his name to the screen, this program will continue looping until it is killed.

  6. #16
    Join Date
    Apr 2008
    Location
    RiceMonsterland, Canada
    Beans
    Hidden!

    Re: someone help me with a bit of bash?

    Quote Originally Posted by swoll1980 View Post
    I don't get how Rice's sig works.
    Code:
    while true; do echo -n "RiceMonster "; done
    While what is true? How does the script run if there is no value that is true?
    It's possible n pretty much every language, and it means the loop will run until either the loop is broken out of, or the program is killed. like XBehave said, true will always be true.
    Code:
    while true; do echo -n "RiceMonster "; done
    Best thread ever

  7. #17
    Join Date
    Jul 2009
    Location
    in a big concret box
    Beans
    110
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Wink Re: someone help me with a bit of bash?

    fancy stuff everybody thanks for you help, like i said i am going to learn more about bash and hopefully get better, very helpful stuff tho

  8. #18
    Join Date
    Jul 2009
    Location
    in a big concret box
    Beans
    110
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Re: someone help me with a bit of bash?

    i did have to remove the dash's in front of enable, disable and status to get it to work in case anyone else tries that code, spot on other than that

  9. #19
    Join Date
    Apr 2008
    Location
    RiceMonsterland, Canada
    Beans
    Hidden!

    Re: someone help me with a bit of bash?

    Quote Originally Posted by andru183 View Post
    i did have to remove the dash's in front of enable, disable and status to get it to work in case anyone else tries that code, spot on other than that
    Sorry, I'm not familiar with ufw, so I didn't know the exact syntax. My mistake.
    Code:
    while true; do echo -n "RiceMonster "; done
    Best thread ever

  10. #20
    Join Date
    Jul 2009
    Location
    in a big concret box
    Beans
    110
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Re: someone help me with a bit of bash?

    Quote Originally Posted by RiceMonster View Post
    Sorry, I'm not familiar with ufw, so I didn't know the exact syntax. My mistake.
    no worries, you did do everything else for me, i don't mind have to take out a dash after that

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •