Jump to content

Bash Script - Random Generator

Hi,

Currently, I've got the following

to produce a random 13 character string, which includes all printable ASCII characters.

#!/bin/bash
LIST="a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z 0 1 2 3 4 5 6 7 8 9 ! £ $ % ^ & ( ) , . / ; ' # [ ] { } : @ ~ < > \ ? * + - = \"  _ |"
RAMPWD=$(cat /dev/urandom | tr -dc "$LIST" | fold -w 13 | head -n 1)
echo "$RAMPWD"

The problem is that sometimes the output results into this:

f~VfrI▒ocgU6[

which is useless for a WEP password and just doesn't work

Is there any other random generator for bash that I could use and still include all printable ASCII characters.

Thank you

Link to comment
Share on other sites

Link to post
Share on other sites

could it be you have " inside the list=" *chars here* "

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, vorticalbox said:

could it be you have " inside the list=" *chars here* "

Thank you,

 

The trouble is I've used the same list in creating permutations and it works fine.

So I'm pretty sure its got something to do with the random generator part. 

 

Thank you

Link to comment
Share on other sites

Link to post
Share on other sites

 

pwgen () {
list=$(cat /dev/urandom |head |openssl  base64 | tr -d \+ |tr -d \/ | cut -c1)
echo $list | tr -d " " | cut -c5-16
}

 

Can Anybody Link A Virtual Machine while I go download some RAM?

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×