Re: stuck on 1 shell variable, not re-updating.

From: Thomas Adam (thomas_adam16_at_yahoo.com)
Date: 07/08/04

  • Next message: Dennis Stosberg: "Re: Pick up a shell session after ssh timeout"
    Date: Thu, 8 Jul 2004 15:15:04 +0100 (BST)
    To: Louie Miranda <lmiranda@gmail.com>, Debian-User <debian-user@lists.debian.org>, shan@team.ph.inter.net
    
    

    --- Louie Miranda <lmiranda@gmail.com> wrote: > #!/bin/bash
    > GEN=`pwgen --no-capitalize -N1`
    > for i in $GEN
    > do
    > echo "update dump set random= '$i'"|mysql -uroot insert
    > done
    >
    > --
    >
    > I have created this shell script, it updates a specific table on a
    > mysql db. Now, the pwgen is a random password generator. When i run
    > this program, it only gets 1 variables on all of my fields on the
    > mysql.

    Haven't tried it but this loop doesn't do anything. When you run the
    comand "pwgen --no-capitalize -N1" as you have it there, only one password
    is returned, so that makes your for loop completely redundant. You
    therefore need to know how many times you're going to loop to make it
    effective, then you can simply do:

    -----------------------------------------------------------
    ####GEN=`pwgen --no-capitalize -N1`
    for i in $(seq <num>) do
    echo "update dump set random= $(pwgen --no-capitalize -N1)"|mysql -uroot
    insert
    done
    ------------------------------------------------------------

    Replacing "<num>" above with a number. If it is not fixed, find some other
    way of looping.

    -- Thomas Adam

    =====
    "The Linux Weekend Mechanic" -- http://linuxgazette.net
    "TAG Editor" -- http://linuxgazette.net

    "<shrug> We'll just save up your sins, Thomas, and punish
    you for all of them at once when you get better. The
    experience will probably kill you. :)"

     -- Benjamin A. Okopnik (Linux Gazette Technical Editor)

            
            
                    
    ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Dennis Stosberg: "Re: Pick up a shell session after ssh timeout"

    Relevant Pages

    • XML to mySQL - Loop issue?
      ... I am trying to loop through a ... XML feeds, pull out some info and place it into a mySQL table. ...
      (comp.lang.php)
    • Re: XML to mySQL - Loop issue?
      ... I am trying to loop through a ... XML feeds, pull out some info and place it into a mySQL table. ...
      (comp.lang.php)
    • Re: XML to mySQL - Loop issue?
      ... I am trying to loop through a ... XML feeds, pull out some info and place it into a mySQL table. ...
      (comp.lang.php)
    • Re: Looping from a fetcharray()
      ... need to do, is loop through the array, displaying each company name. ... // Assumes $result is MySQL Result Resource ... // Assumes $NumRows has already been populated with number of return ...
      (comp.lang.php)