Berkeley CSUA MOTD:2008:July:14 Monday <Sunday, Tuesday>
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2008/7/14-16 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:50557 Activity:moderate
7/14    Shell Programming question: I want to call a script with 1 arg
        and have it figure out whether $1 is a MAC address or an IP address
        and then do call the appropriate function.  What is the best way
        to do this, given that sh/bash/ksh do not have something like
        the =~ in perl.  Check for exit status of grep, or is there a
        a better way?  For the moment, let's just say the two tests are:
          echo $1 | fgrep : > /dev/null && echo isMAC || echo notMAC
          echo $1 | fgrep . > /dev/null && echo isIP || echo notIP
          and if neither, then Usage()
        I want to avoid requiring the user to either do "-i IP" or "-m MAC".
        Note: this doesn't have to do extensive syntax checking ... it's
        not a security application.  Just trying to save typing.
        \_ You may want to recheck your assumption of bash not having =~.
           \_ Thanks for that information.  I didn't know know about that.
              Although right now it is in sh.  Any portable pure sh ideas?
              I'm really interested in what is the "right" way to do this,
              rather than just coming up with something which works.
              \_ "right" depends on your situation. If you actually need
                 to support old systems, or be portable across many systems,
                 then maybe you should stick with sh. If you know your
                 audience is all going to have bash or whatever (and that
                 is not at all unlikely these days), then I see no good
                 reason to suffer under older, less capable tools.
              \_ Dude, it's a sh script.  If it works, it works.  Seriously.
                 Stick it in a function if it looks too ugly and then forget
                 about it.  If you need something to be maintainable or
                 it's a called enough there is any concern about it being
                 too slow you are going to have to bite the bullet and use
                 a reasonable scripting language.  Otherwise just make it work
                 and move on to something that is worth spending time on.
              \_ I think "right" in this case, means readable and maintainable
                 by the next poor guy that has to come along. Just document
                 your code and you will be fine.
              \- I think one way to distill the question is "how do i get =~
                 in sh" ... would you do "echo $string | egrep <regexp>" + $?
                 to get exit status of the grep ... I think the case approach
                 below is nice and clean as long as you are ok with something
                 like *:*:*:*:*:* for MACs and *.*.*.* for IPs, and dont need
                 "true" regexps.
                 "true" regexps. I wouldnt use awk to test, but maybe if you
                 need to mangle.
        \_ Why would you do this in a shell progam?
        \_ use case:

        found="NO"
        case "$1" in
             *:*)    echo "isMAC"; found="YES";;
             *.*)    echo "isIP"; found="YES";;
             *)      if [ "$found" = "NO" ] ; then
                        echo "NOT MAC" ; echo "NOT IP";
                     fi
                     ;;
        esac
2008/7/14 [Politics/Domestic/California, Reference/BayArea] UID:50558 Activity:nil 92%like:50565
7/14    Mythbusters need people in the bay area to help out in September
http://blog.makezine.com/archive/2008/07/help_mythbusters_recreate.html
2008/7/14-16 [Politics/Domestic/California] UID:50559 Activity:nil
7/14    Customers line up in front of IndyMac bank branches in hopes of pulling
        out cash
        http://tinyurl.com/5k5b72 (yahoo.com)
2008/7/14-17 [Politics/Domestic/Crime] UID:50560 Activity:nil
7/14    Knife crime: 60/day in UK
        http://tinyurl.com/6ytub5 [telegraph]
        Prime minister says theyr'e going to do something about it.
        http://news.bbc.co.uk/1/hi/uk/7502569.stm  [bbc]
        \_ Gun deaths: 80/day in the US.
           Gun crime: 1300/day.
        \_ It would be worse if assault knives were legal
2008/7/14-17 [Politics/Domestic/Election] UID:50561 Activity:nil
7/14    Damn that Liberal Media!
        http://preview.tinyurl.com/5qwoz9 (Obama New Yorker Cover)
        \_ Yes, incompetent lefties sure do the darndest things.
        \_ It's a stupid cover, but part of the problem is it is really
           hard to do satire when the people you are making fun of are
           beyond satire.  I mean shit, sometimes the Colbert Report sounds
           scarilly like a real right wing talk show.
           \_ http://www.freerepublic.com/focus/f-news/2045045/posts
           \_ http://michellemalkin.com/2008/07/14/grow-a-pair-obama
            \_ Your point is what?  That Malkin is insane?  We knew
               that already.
2008/7/14 [Uncategorized] UID:50562 Activity:nil
7/14    DOOM!!!!
        \_ yay!
2008/7/14-17 [Politics/Foreign/MiddleEast/Iraq] UID:50563 Activity:nil
7/14    Obama's plan to end the war in 16 months:
        http://preview.tinyurl.com/556cz4 (NYT)
        \_ Oops, sorry Obama, that's not what Maliki actually said
           http://news.bbc.co.uk/2/hi/middle_east/7504571.stm
           \_ Oops, sorry President Maliki, your own office used the word
              "withdrawal" in its transcription of your speech and then
              published it as such.
        \_ Hear, hear.
2008/7/14-23 [Finance/Banking] UID:50564 Activity:nil
7/14    If you have any bank deposits over 100k, I would say now is the time
        change that ASAP.
        http://online.wsj.com/article/SB121605305718551305.html
        \_ This sentiment is 100% correct.  I'm not worried about you fools--
           it's your parents and relatives.  Small business owners have it
           roughest because payroll can easily be > $100K.
        \_ Just put your money in a bank like Well's Fargo or BofA.
           \_ Wells is definitely a safe bet, but I'm not so sure about
              BofA.  Are you certain they aren't exposed?  Keep in mind
              that they bought Countrywide as well.
              \_ I think they are both "too big to fail" though WFC is
                 certainly the stronger institution. I don't have $100k
                 in cash anyway, so it is all moot.
           \_ What about Charles Schwab?  Is it safe?
        \_ I am buying KBE (seriously).
           \_ Reversion to mean strategy?  I'd say that's probably a good
              short term bet and an extremely lousy long term bet.
              \_ I actually think it is a good short and long term strategy,
                 though I will certainly take some profits on any move up.
                 \_ Why are you long on financials?  Just playing
                    devils advocate, or do you have a good macro
                    justification?  The problems with financials are not
                    purely sentiment, they have a solvency issue.
                    \_ No, I actually got 100% out of financials back in
                       Dec, when my stops got hit. I have been itching to
                       get back in and am starting to buy now. I think
                       this is a selling climax right now, brought about
                       by the IMB failure. I am sure some more banks will
                       fail, but not too many of them. I am looking at
                       a recently released (today) research report from
                       Citibank. They are saying that they are revising
                       BAC 2009 profit forcast down from $3.57 to $2.91.
                       This is a huge drop, to be sure, but implies a
                       forward P/E of 7. The banking sector will probably
                       recover in 2010, making it an even better deal then.
                       Buying on drops has worked our pretty well for me,
                       though I admit I am often early, like most
                       contrarians.
                       Check out the chart on these three the last time
                       we had a housing meltdown:
                       http://tinyurl.com/6pgkpm
                       \_ Update: the BAC I bought for 20 and change a week
                          ago is now up over 30.
2008/7/14-17 [Reference/BayArea] UID:50565 Activity:nil 92%like:50558
7/14    Mythbusters need people in the bay area to help out in September
        http://preview.tinyurl.com/5gewgv [makezine]
        \_ "Dear Mythbuster Friends,
            Thank you very much for your interests in participating in our
            upcoming episode.  At this time, we will continue to collect your
            contact information and will contact you soon for the next step
            in the registration process.  Due to the overwhelming response, we
            cannot guarantee everyone a volunteer spot.  However, we will do
            our best.  We appreciate your support and thank you for helping us
            make a great show."
           Still, thank you for posting the opportunity.
2008/7/14-16 [Science/GlobalWarming] UID:50566 Activity:moderate 60%like:50602
7/14    Where does oil in the sea come from? (63% natural seeps)
        http://www.noia.org/website/article.asp?id=129
        \_ Do you want to have sex with Dirk Pitt too?
        \_ Wow, you say that like adding over half again as much through
           man made sources isn't alarming.  Especially considering how
           natural seeps are generally in stable locations.  Hey look,
           deforestation isn't a problem because look over there!  Deserts!
           \_ non sequitur.  Note that transporting oil is more cause than
              drilling.
              \_ Cars kill more people than illegal handguns, so obviously
                 we shouldn't worry about illegal handguns.
        \_ I know a jerk-ass who advocates dumping his motor oil down the
           drain since there is already so much oil the bay already.
           Fuck both of you.
           F*** both of you.
           \_ Call the cops on that idiot. -!pp
              \_ Agreed. !pp && !op
           \_ I don't advocate throwing more oil in the ocean.  What's your
              problem? -op
2008/7/14-16 [Finance, Finance/Investment] UID:50567 Activity:nil
7/14    Onion once again more like reality than "real news"
        http://www.theonion.com/content/news/recession_plagued_nation_demands
2008/7/14-23 [Politics/Domestic/President/Clinton, Politics/Domestic/Election] UID:50568 Activity:nil
7/14    The Fox Newsification of AP:
        http://www.thecarpetbaggerreport.com/archives/16193.html
2008/7/14-16 [Reference/RealEstate] UID:50569 Activity:kinda low
7/14    Ahem, in case you've all forgotten... HOUSING ONLY GOES UP!
        BUY NOW BEFORE YOU'RE PRICED OUT!
        \_ Hold on, is this in response to the banking industry, where
           you believe that owning a home is a good hedge against a collapsing
           banking, or... that you are being sarcastic and waiting for the
           banking industry to drag down the housing market and laughing
           at people who are tied up to their homes?
        \_ you're doing a great job scoring points against your imaginary
           friends.
           \_ tom is imaginary?  Dang, that explains a lot.
              \_ Please provide a reference where I suggested to anyone that
                 housing only goes up, or that they should buy before they're
                 priced out.  Idiot.  -tom
        \_ I agree.  Now is a great time to get a good deal.  Unfortunately it
           is much harder to get a loan.  I've found quite a few cash flow
           positive investment properties lately.  Also, all of the big
           investment groups are gathering cash to buy up all of the available
           properties while everyone else shies away.
        \_ Why didn't the Great Swami warn us this was going to happen?
2008/7/14-23 [Politics/Foreign/Asia/China, Politics/Foreign/MiddleEast/Iraq, Politics/Foreign/Asia/Korea] UID:50570 Activity:nil
7/14    Source of the torture techniques used at Gitmo revealed to be...
        Chinese Torture Tactics from the Korean War:
        http://www.nytimes.com/2008/07/02/us/02detain.html
2024/11/22 [General] UID:1000 Activity:popular
11/22   
Berkeley CSUA MOTD:2008:July:14 Monday <Sunday, Tuesday>