Well, since you can use Ruby in a Bash script, here is a Ruby one-liner for ya ;)
LENGTH=16 ruby -e 'ENV["LENGTH"].to_i.times { print Random.rand(33..126).chr.to_s }; puts'
To change the set of characters you want to use, just modify the ASCII codes in the rand(..) function.