- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Help me with this shell script pls..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 01:11 AM
тАО08-27-2007 01:11 AM
Help me with this shell script pls..
1.ab
2.ac
3.ad
.
.
.
az
aba
abc
abd
.
.
.
.......till a9999999........9........9
can any 1 tel me how to do it.i have loaded the array for u in the below program.Thanks in advance.
#!/bin/sh
j=0;
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9
do
dod[$j]=$i;
echo "${dod[$j]}";
i=$i+1;
j=$j+1;
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 05:36 AM
тАО08-27-2007 05:36 AM
Re: Help me with this shell script pls..
aa
ab
ac
ad
.
.
.
ax
ay
az
ba
bb
bc
bd
You are going to need multiple loops. Just incrementing the variable by 1 isn't doing anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 09:13 AM
тАО08-27-2007 09:13 AM
Re: Help me with this shell script pls..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 02:47 PM
тАО08-27-2007 02:47 PM
Re: Help me with this shell script pls..
Do you realize how many solutions you are asking? If was ignore the special case you seem to request for spaces not at the end, there will be N to the power of N solutions where N is the number of characters to use.
So if the string just goes from a .. c then there are 9 solutions. But from a .. j gives 10 billion solutions. It goes uphill very quickly form there. Exponentially!
Clearly not a job for a shell script.
Not really a job for perl either, but for a real C program... if it is a real job to begin with and not a 'student exam question'.
The seemingly 'growing' string length can be handle by adding a 'space' in front of the a .. z sequence.
You also seem to have an odd end condition:
'a99999...9' !
not
'z99999...9' ?
nor
'999999...9' ?
Anyway...
Here is SAMPLE solution in PERL.
A REAL solution must be in a compiled language and would not 'built' the output string over an over but rather 'maintain' it while it maintains the counters.
use strict;
use warnings;
my (@current,@symbols,$max,$j);
my $count = 0;
my $total = 0;
my $i = 0;
my $very_last = 0;
for (' ', 'a'..'c', '0'..'2') {$current[$count] = 0; $symbols[$count++] = $_}
$count--;
$max = $count**$count;
while (!$very_last) {
my $text = '';
for $j (0..$count) { $text .= $symbols[$current[$j]] }
printf "%7d $text\n", $total++, $text;
for $j (0..$count) {
if ($j == $count) { $very_last++; last }
my $x = $current[$j];
if (($j && $x++ < $count) || $x++ < 3 ) {
$current[$j] = $x;
last;
} else {
$current[$j] = 1;
}
}
}
print "Lines: $total\n"
Sample results below....
Close to what is requested... all values are there... for a small subset.
( Send money and I'll get them in the right order :-)
Enjoy!
Hein.
0
1 a
2 b
3 c
4 aa
5 ba
6 ca
7 ab
8 bb
9 cb
10 ac
11 bc
12 cc
13 a0
14 b0
15 c0
16 a1
17 b1
18 c1
19 a2
20 b2
21 c2
22 aaa
:
27988 a12222
27989 b12222
27990 c12222
27991 a22222
27992 b22222
27993 c22222
Lines: 27994
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 02:49 PM
тАО08-27-2007 02:49 PM
Re: Help me with this shell script pls..
use strict;
use warnings;
my (@current,@symbols,$max,$j);
my $count = 0;
my $total = 0;
my $i = 0;
my $very_last = 0;
for (' ', 'a'..'c', '0'..'2') {
$current[$count] = 0;
$symbols[$count++] = $_;
}
$count--;
while (!$very_last) {
$total++;
my $text = '';
for $j (0..$count) { $text .= $symbols[$current[$j]] }
print $text,"\n";
for $j (0..$count) {
if ($j == $count) { $very_last++; last }
my $x = $current[$j];
if (($j && $x++ < $count) || $x++ < 3 ) {
$current[$j] = $x;
last;
} else {
$current[$j] = 1;
}
}
}
print "Lines: $total\n"
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 04:29 PM
тАО08-27-2007 04:29 PM
Re: Help me with this shell script pls..
The iteration can be simply done with a stacked list with a an iterator:
${STACK:$ITERATOR:1}
Can easy go for infinite depth.. but it's output could get messy after a while.
In any case, the original post still looks like it's set up to try brute-force a password..
Karthik, what is the purpose of the list supposed to be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 05:24 PM
тАО08-27-2007 05:24 PM
Re: Help me with this shell script pls..
Easy? I respectfully disagree.
The code perhaps, sure.
But not the execution.
Maybe I'm missing something and my math is terribly wrong wrong but here is my thinking:
Taking a .. c you can make 3*3*3 = 27 combo's right? And a few more if you add in trailing spaces, as per example below?
To stay with comprehensive numbers, let's now limit ourself to an 11 character alphabeth : a..k.
Pick 1 -> 11 options
Pick twice --> 11*11 = 121 options
Pick three ---> 11*11*11 = 1331 options
Pick 11 ----------> 11 to the power of 11 is 285,311,670,611 options
Average output is 11-ish bytes (count seperator)
So for that miniscule subset the script will generate 3 Terabyte of data. Somehow I'm thinking a shell script will have just a tad too much overhead to finish that in a reasonable time window.
Make the alphabeth 13 long and we are up to 4000 Terabyte.
Cheers,
Hein.
Changing script above to read:
>>> for (' ', 'a'..'c') {
We get:
$ perl tmp.pl
a
b
c
aa
ba
ca
ab
bb
cb
ac
bc
cc
aaa
baa
caa
aba
bba
cba
aca
bca
cca
aab
bab
cab
abb
bbb
cbb
acb
bcb
ccb
aac
bac
cac
abc
bbc
cbc
acc
bcc
ccc
Lines: 40
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 05:40 PM
тАО08-27-2007 05:40 PM
Re: Help me with this shell script pls..
A few while loops, and you're done. Completely dynamic output creation, stacking letters on to each other.
I've got one here that's about 40 lines long that (just mucking around) is brute-forcing a 32 character password. Admittadly, it's only been running for about 3 mintues thus far ;) I give it another 10 or so :P
[root@logs tmp]# ./test.sh
1: a
2: b
3: c
4: aa
5: ab
6: ac
7: ba
8: bb
9: bc
10: ca
11: cb
12: cc
13: aaa
14: aab
15: aac
16: aba
17: abb
18: abc
19: aca
20: acb
21: acc
22: baa
23: bab
24: bac
25: bba
26: bbb
27: bbc
28: bca
29: bcb
30: bcc
31: caa
32: cab
33: cac
34: cba
35: cbb
36: cbc
37: cca
38: ccb
39: ccc
The output of it limited to abc/3-chara-long.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 07:28 PM
тАО08-27-2007 07:28 PM
Re: Help me with this shell script pls..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 07:39 PM
тАО08-27-2007 07:39 PM
Re: Help me with this shell script pls..
-=-=-=-=-=-=-=-=-=-=-=-=-=-
#!/bin/bash
STACK="abc"
MAX_DEPTH=3
DEPTH=0
TOT=0
declare -a STUMP ITERATOR
ITERATOR[$DEPTH]=0
while [ $DEPTH -lt $MAX_DEPTH ]
do
let TOT++
COUNT=0
STRING=""
while [ $COUNT -le $DEPTH ]
do
STRING="${STRING}${STACK:${ITERATOR[$COUNT]}:1}"
let COUNT++
done
printf "%7s: %s\n" $TOT "${STRING}"
COUNT=$DEPTH
LAST=0
while [ $COUNT -ge 0 ]
do
if [ ${ITERATOR[$COUNT]} -eq $((${#STACK} - 1)) ]
then
ITERATOR[$COUNT]=0
else
LAST=1
let ITERATOR[$COUNT]++
continue 2
fi
let COUNT--
done
if [ $LAST == 0 ]
then
let DEPTH++
ITERATOR[$DEPTH]=0
fi
done
-=-=-=-=-=-=-=-=-=-=-=-=-=-