Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Looking for a command that is just like the goto but for os x bash

Started 1 month, 3 weeks ago by Bone11409
Hey I need a command like goto but for the os x leopard using bash I have look on the net but have not found any thing.
Site: LinuxQuestions.org - where Linux users come for help  LinuxQuestions.org - where Linux users come for help - site profile
Forum: Other *NIX  Other *NIX - forum profile
Total authors: 3 authors
Total thread posts: 9 posts
Thread activity: no new posts during last week
Domain info for: linuxquestions.org

Other posts in this thread:

druuna replied 1 month, 3 weeks ago
Hi, Bash does not have a goto statement. Depending on what you want to do, which you do not mention, you need to use some other construction. Post the problem (as detailed as possible) and we are probably able to help you with a solution. Hope this helps.

Bone11409 replied 1 month, 3 weeks ago
Ok I am trying to compare this variable gateway=$(netstat -r | grep default | awk '{print $2}' to a list of 5 different gateway address's and then when it cycles threw and finds the one it match's to then it will skip the comparing of the rest and give me another variable to show that gateway's name. Here's kind of what I had in mind. #!/bin/bash gateway=$(netstat -r | grep default | awk '{...

catkin replied 1 month, 3 weeks ago
Code: #!/bin/bash gateway=$(netstat -r | grep default | awk '{print $2}' case "$gateway" in '10.184.16.1' ) name=${1}floor ;; '10.184.32.1' ) name=${2}floor ;; * ) <error commands> esac <line1 commands> exit

Bone11409 replied 1 month, 3 weeks ago
Hey I just try your script here on my laptop and it did not work for me. Also could you walk me threw that command I have not seen it before. command substitution: line 6: syntax error near unexpected token `newline' /Users/bone/Desktop/fixodtest: command substitution: line 6: ` '10.184.16.1' ' /Users/bone/Desktop/fixodtest: line 6: syntax error near unexpected token `;;' /Users/bone/...

catkin replied 1 month, 3 weeks ago
Quote: Originally Posted by Bone11409 Hey I just try your script here on my laptop and it did not work for me. Also could you walk me threw that command I have not seen it before. command substitution: line 6: syntax error near unexpected token `newline' /Users/bone/Desktop/fixodtest: command substitution: line 6: ` '10....

Bone11409 replied 1 month, 3 weeks ago
Here's what I have come up with it's simple and it work's #!/bin/bash gateway=$(netstat -r | grep default | awk '{print $2}') if [ "$gateway" = "10.184.16.1" ]; then name=$"1floor" fi if [ "$gateway" = "10.184.32.1" ]; then name=$"2floor" fi echo "$name"

catkin replied 1 month, 3 weeks ago
Quote: Originally Posted by Bone11409 Here's what I have come up with it's simple and it work's #!/bin/bash gateway=$(netstat -r | grep default | awk '{print $2}') if [ "$gateway" = "10.184.16.1" ]; then name=$"1floor" fi if [ "$gateway" = "10.184.32.1" ]; then name=$"2floor" fi echo "$name" ...

Bone11409 replied 1 month, 3 weeks ago
No reason just over looked it

 

Top contributing authors

Name
Posts
Bone11409
5
user's latest post:
Looking for a command that is...
Published (2009-11-08 11:15:00)
No reason just over looked it
catkin
3
user's latest post:
Looking for a command that is...
Published (2009-11-08 01:33:00)
Quote: Originally Posted by Bone11409 Here's what I have come up with it's simple and it work's #!/bin/bash gateway=$(netstat -r | grep default | awk '{print $2}') if [ &quot;$gateway&quot; = &quot;10.184.16.1&quot; ]; then name=$&quot;1floor&quot; fi if [ &quot;$gateway&quot; = &quot;10.184.32.1&quot; ]; then name=$&quot;2floor&quot; fi echo &quot;$name&quot;...
druuna
1
user's latest post:
Looking for a command that is...
Published (2009-11-07 04:32:00)
Hi, Bash does not have a goto statement. Depending on what you want to do, which you do not mention, you need to use some other construction. Post the problem (as detailed as possible) and we are probably able to help you with a solution. Hope this helps.

Related threads on "LinuxQuestions.org - where Linux users come for help":

Related threads on other sites:

Thread profile page for "Looking for a command that is just like the goto but for os x bash" on http://www.linuxquestions.org. This report page is a snippet summary view from a single thread "Looking for a command that is just like the goto but for os x bash", located on the Message Board at http://www.linuxquestions.org. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity