[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



--- 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



Reply to: