Re: stuck on 1 shell variable, not re-updating.
From: Thomas Adam (thomas_adam16_at_yahoo.com)
Date: 07/08/04
- Previous message: Jesse Rosenthal: "Color Distortion in KDE"
- In reply to: Louie Miranda: "stuck on 1 shell variable, not re-updating."
- Next in thread: Louie Miranda: "Re: stuck on 1 shell variable, not re-updating."
- Reply: Louie Miranda: "Re: stuck on 1 shell variable, not re-updating."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Jesse Rosenthal: "Color Distortion in KDE"
- In reply to: Louie Miranda: "stuck on 1 shell variable, not re-updating."
- Next in thread: Louie Miranda: "Re: stuck on 1 shell variable, not re-updating."
- Reply: Louie Miranda: "Re: stuck on 1 shell variable, not re-updating."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|