Sponsored Content
Operating Systems Linux Ubuntu Random insertion of letters to password Post 302506014 by vanid on Friday 18th of March 2011 09:17:02 AM
Old 03-18-2011
reply

here is my code:

Code:
#!/usr/local/bin/expect —f
proc insertchar {c} {
global password
set password [linsert $password \
[rand [expr 1+[llength $password]]] $c]
}
set _ran 5
proc rand {n} {
global _ran
set period 233280
set _ran [expr ($_ran*9301 + 49297) % $period]
expr int($n*($_ran/double($period)))
}
send_user "rand n\n"
send_user "insertchar c\n"
set minnum 2
set minlower 4
set minupper 4
expect "$ " 
set pwd "vani"
set password [join "$pwd" ""]
for {set i 0} {$i<$minnum} {incr i} {
send "$password [rand 10]\n"
}
for {set i 0} {$i<$minlower} {incr i} {
send "$password [format "%c" [expr 0x61 + [rand 26]]]\n"
}
for {set i 0} {$i<$minupper} {incr i} {
send "$password [format "%c" [expr 0x41 + [rand 26]]]\n"
}

result for above code is:
Code:
rand n
insertchar c
vani 4
vani 8
vani n
vani v
vani o
vani j
vani A
vani E
vani Z
vani L

but i want the letters to be inserted in to the string by picking up randomly like :
Code:
v1ani
Vani
Va1ni

so that i can test commands for all invalid cases also.

---------- Post updated at 08:15 AM ---------- Previous update was at 08:14 AM ----------

thank you again and please get back to be...with answer

---------- Post updated at 08:17 AM ---------- Previous update was at 08:15 AM ----------

please help me out off this...this logic i am not able to write....

Last edited by pludi; 03-18-2011 at 11:22 AM..
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate a random password

Hello All... Can someone help me generate a random password which will be 7 characters long which contains alpha-numeric characters using shell script. I am looking to store the output of the script that generates the password to a variable within a script and use it as the password. ... (5 Replies)
Discussion started by: chiru_h
5 Replies

2. Programming

Generate Random Password in C

I need a function to generate a random alphanumeric password in C code. It needs to be between 6-8 characters and follow the following rules: Reject if same char appears # time: 4 or more Reject if same char appears consecutively: 3 or more I have the following random password working for... (2 Replies)
Discussion started by: vjaws
2 Replies

3. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

4. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

5. AIX

Random password generation

Hello, I have created a script to generate a random password on Linux/Solaris, but I simply cannot use it on my AIX VMs since Bash isn't installed on them. I need a password that is randomly created with the following... (12 Replies)
Discussion started by: gfroute
12 Replies

6. UNIX for Beginners Questions & Answers

Random letters

Hi there, first of all this is not homework...this is a new type of exercise for practicing vocabulary with my students. I have a file consisting of two columns, separated by a tab, each line consisting of a word and its definition, separated by a line break. What i need is to replace a... (15 Replies)
Discussion started by: eldeingles
15 Replies

7. Shell Programming and Scripting

Random Password generator with 2 digits and 6 characters

I am using the below to random generate a password but I need to have 2 numeric characters and 6 alphabetic chars head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '' 6USUvqRB ------ Post updated at 04:43 PM ------ Any Help folks - Can the output be passed onto a sed command to... (9 Replies)
Discussion started by: infernalhell
9 Replies
UBUNTU-BUILD(1) 					      General Commands Manual						   UBUNTU-BUILD(1)

NAME
ubuntu-build - command-line interface to Launchpad build operations SYNOPSIS
ubuntu-build <srcpackage> <release> <operation> DESCRIPTION
ubuntu-build provides a command line interface to the Launchpad build operations. OPERATIONS
Listed below are the available operations for ubuntu-build: status Outputs the build status of the package on Launchpad on all architectures. retry Requests that the package has another attempt at rebuilding from source. This will only work if the package has Failed to build on Launchpad. rescore Requests that the package's build priority be raised in the build queue. Only members of the Launchpad build administrators may issue this operation, and it may only be performed on packages which Need building. OPTIONS
Listed below are the command line options for ubuntu-build: -h or --help Display a help message and exit. Retry and rescore options: These options may only be used with the 'retry' and 'rescore' operations. -a ARCHITECTURE, --arch=ARCHITECTURE Rebuild or rescore a specific architecture. Valid architectures include: amd64, sparc, powerpc, i386, armel, armhf, ia64, lpia, hppa. Batch processing: These options and parameter ordering is only available in --batch mode. Usage: ubuntu-build --batch [options] <package>... --batch Enable batch mode --series=SERIES Selects the Ubuntu series to operate on (default: current development series) --retry Retry builds (give-back). --rescore=PRIORITY Rescore builds to <priority>. --arch2=ARCHITECTURE Affect only 'architecture' (can be used several times). Valid architectures are: amd64, sparc, powerpc, i386, armel, armhf, ia64, lpia, hppa. AUTHORS
ubuntu-build was written by Martin Pitt <martin.pitt@canonical.com>, and this manual page was written by Jonathan Patrick Davies <jpds@ubuntu.com>. Both are released under the terms of the GNU General Public License, version 3 or (at your option) any later version. ubuntu-dev-tools June 2010 UBUNTU-BUILD(1)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy