Random insertion of letters to password


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu Random insertion of letters to password
# 1  
Old 03-18-2011
Random insertion of letters to password

Hi,,

Here i have attached a text file where iam facing problem in my code.

Please read the file and help me out of this issue..


Thanks in advance

Last edited by pludi; 03-18-2011 at 07:29 AM..
# 2  
Old 03-18-2011
What is your code, where are you facing a problem, what error do you get, ...?
# 3  
Old 03-18-2011
Firstly thank you so much for replying....
actually i am new to expect:

I am able to execute the commands automatically using expect for telnet session.

Now my requirement is:
as of now those commands are all valid one's, which i am seeing on output but

now i want them to automate for all invalid conditions like..
when commands are unexpectedly typed wrong by human manually, it show corresponding error message...so now i want the same effect using expect automatically for all valid commands which i have done it for.

the attachment is what i have written sample code for randomizing passwords ..i tried this to get idea to my actual problem. that's it
please if you again not clear on question: please do ask i will try to elaborate it clearly once again

thank you
# 4  
Old 03-18-2011
Again, where is your code? Please don't use attachments to post your code if it's basically just a few lines, and especially do not write your questions into the attachment. Instead, give a proper explanation of what you're doing, what you're trying to do, where you're stuck, and what you've tried.
# 5  
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..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

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

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

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

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

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

7. 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
Login or Register to Ask a Question