LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > Subjectively
User Name
Password

Notices

This blog points to articles written on http://kirk.webfinish.com. These articles are mainly about shell scripting, PHP, and postgresql on Ubuntu and OS/X.
  1. Old Comment

    simple bash password generator

    a little bit offtopic but here's what i made to create a 1/0 simple generator using /dev/urandom also.
    like in Yes/No questions, im asking to this program sometimes xD
    Code:
    #!/bin/sh
    let v=0x`head -c 1 /dev/urandom | hd | awk '{print $2}'`
    echo $v/127 | bc
    Posted 11-24-2009 at 09:58 PM by Web31337 Web31337 is offline
  2. Old Comment

    bash shell script to use getopts with gnu style long positional parameters

    Quote:
    Originally Posted by padeen View Comment
    A quick question, you, and the examples in the docs, use "eval set -- $args". I can't figure out the reason for the eval. Couldn't you simply use "set -- $args" to put the params into $1, $2, etc.

    Cheers,
    Nick
    The eval is there because parameters (like long file names with spaces) will get expanded to multiple parameters. I can add quotes around the parameters to "group" them again, but I need the eval to get 'set' to accept the quoted arguments.

    /bithead
    Posted 11-17-2009 at 12:46 PM by roybal roybal is offline
  3. Old Comment

    bash shell script to use getopts with gnu style long positional parameters

    Coincidentally, I've just gone through this very exercise. Your approach is an interesting alternative to mine, and I'll bear it mind for the future.

    FYI, my approach in this case was to simply use all short options for the script itself, and then convert them to the long options in the case statement. It wouldn't work for something with a large set of options, too messy.

    For example, the application takes a long option of --file filename, I use -f in the script:
    Code:
    case $opts in
      f)
         file="--file $OPTARG"
         ;;
    esac
    
    # call the app
    app "$file"
    A quick question, you, and the examples in the docs, use "eval set -- $args". I can't figure out the reason for the eval. Couldn't you simply use "set -- $args" to put the params into $1, $2, etc.

    Cheers,
    Nick
    Posted 11-04-2009 at 06:13 AM by padeen padeen is offline

  



All times are GMT -5. The time now is 01:42 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration