posted
wow, I'm not sure I even want to try to figure out your logic in this . . .
And you even choose to invoke perl in it. If you're going to use perl, just freakin' use perl.
Also, let me introduce you to the notion of comments. Write a comment saying what each line is doing (less in a literal sense, more in an evocative sense).
I suspect its not creating the numbers because of output buffering -- the file isn't being created until after all the echos are "stacked". A quick "fix" might be to flush the output after each echo. However, this is both kludgy and will quickly become inefficient. Consider using some sort of array with string indices, either in the shell or using awk (awk would be far better) to hold how many times a given userid has been used.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
Blayne Bradley
unregistered
posted
quote: #This script will generate a randomly created user id and password from the redhat linux dictionary
spc1=", " spc2=" "
#assings a path to a variable #then it assigns numbers to the beginning of each line in the redhat dictionary #counts the number of words total
echo "Names: User ID's: PASSWORDS CLASSIFIED:" #output format while read line #reads lines of names from file "clients" do
w=$(echo $line | cut -d' ' -f2 | cut -c1-3) #assigns the first 3 chars from the last name to w q=$(echo $line | cut -c1-3) #assigns the first 3 chars from first name to q
uida=$w$q #assigns w and q to uida uidb=$uida assigns a double of uida to uidb
num=0 #initializes num to 0 while grep "$uidb" $2 >& /dev/null #if if finds a multiple of a userid do loop do let $num=$num+1 #assigns the value of num and increments it by 1 for each multiple usr id uidb=$uida$num #the userid + the number becomes uidb done
echo $uidb >> $2 #testing
#creates a random number by invoking pearl, and using grep, finds the line that matches the given number #using sed, blanks out the number and the user id
rnum1=$(perl randm.pl $nwords) idnum1=^"$rnum1": pw1=$(grep "$idnum1" mywords | sed 's/^[0-9]*://') rnum2=$(perl randm.pl $nwords) idnum2=^"$rnum2": pw2=$(grep "$idnum2" mywords | sed 's/^[0-9]*://')
I invoked pearl to get a random number, I don't know pearl so I don't code in it, I used pearl function because it was suggested to me.
quote: boivin, chris brown, kris cizauskas, nick cornell, philip cuplinskas, justin deangelis, nick dewan, kanwaljeet glashan, jeff godbout, samuel hall, michael jonas, tommie jones, tom jonsson, tomas katsigiannis, nektarios larivee, benoit manning, raymond manson, rayleen manzarek, ray moufawad, habib needelman, chris niedzviecki, benjamin ohanian, arlen rideough, eric singer, mark viapiano, francis zey, adam
posted
ok after fiddling around with some testing, I realize it is giving a number but its not outputting it with the $output variable, can aynone tell me whats wrong?
IP: Logged |
posted
Write outline to stderr directly before you echo it. Ponder this. Try writing the pieces that seem wrong to stderr directly after their creation, and ponder this. Perhaps test other points.
This is called debugging.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
Blayne Bradley
unregistered
posted
quote: #This script will generate a randomly created user id and password from the redhat linux dictionary
#asgings a path to a variable #then it assigns numbers to the beginning of each line in the redhat dictionary #counts the number of words total
echo "Names: User ID's: PASSWORDS CLASSIFIED:" > sec #output format echo "" >> sec echo "" >> sec while read line #reads lines of names from file clients do
w=$(echo $line | cut -d' ' -f2 | cut -c1-3) #assigns the first 3 chars from the last name to w q=$(echo $line | cut -c1-3) #assigns the first 3 chars from first name to q
uida=$w$q #assigns w and q to uida uidb=$uida #assigns uida to uidb num=0 #initializes num to 0
while grep "$uidb" $2 >& /dev/null #if if finds a multiple of a userid do loop do let num++ #assigns the value of num and increments it by 1 for each multiple usr id uidb=$uida$num #the userid + the number becomes uidb done
echo $uidb > $2 #phony output that annoyed me, so now it is decoration
#creates a random number by invoking pearl, and using grep, finds the line that matches the given number #using sed, blanks out the number and the user id
rnum1=$(perl randm.pl $nwords) idnum1=^"$rnum1": pw1=$(grep "$idnum1" mywords | sed 's/^[0-9]*://') rnum2=$(perl randm.pl $nwords) idnum2=^"$rnum2": pw2=$(grep "$idnum2" mywords | sed 's/^[0-9]*://')
posted
Blayne, did you every try posting this at a forum more dedicated to this kind of thing? I'm not trying to discourage you from posting it here, but you might find that there are more people who can help you at other forums.
Posts: 1621 | Registered: Oct 2001
| IP: Logged |
Blayne Bradley
unregistered
posted
... if I knew other forums.....
IP: Logged |