[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby for Sysadmin

Ron Mr.

10/2/2006 3:17:00 PM

I need to write a script that pulls usernames our of a file that is
formatted like the following.

"ADLER, CHARLES DAVID" 00-9388 x0753 Engineering
"ANSELL, ROBERT D" 14-2675 x1624 Sales
"BIANCHI, CHRISTOPHER" 12-2275 x3280 Marketing
"CAPOZZI, MICHAEL B" 08-3191 x8035 Manufacturing

The last column is what group the user is in.
The username needs to be the initials plus the first three letters of
the group for example...

cdaeng

The GECOS field would be "Charles David Adler 00-9388 x0753 Engineering"

I also need to have it use a default password or "p@ssw0rd!"

Any tips or source code examples would be great, thanks!

--
Posted via http://www.ruby-....

14 Answers

James Gray

10/2/2006 3:24:00 PM

0

On Oct 2, 2006, at 10:17 AM, Ron Mr. wrote:

> I need to write a script that pulls usernames our of a file that is
> formatted like the following.
>
> "ADLER, CHARLES DAVID" 00-9388 x0753 Engineering
> "ANSELL, ROBERT D" 14-2675 x1624 Sales
> "BIANCHI, CHRISTOPHER" 12-2275 x3280 Marketing
> "CAPOZZI, MICHAEL B" 08-3191 x8035 Manufacturing
>
> The last column is what group the user is in.
> The username needs to be the initials plus the first three letters of
> the group for example...
>
> cdaeng
>
> The GECOS field would be "Charles David Adler 00-9388 x0753
> Engineering"
>
> I also need to have it use a default password or "p@ssw0rd!"
>
> Any tips or source code examples would be great, thanks!

Try reading the lines one at a time. See if you can locate the name
and group. Then try munging those into what you need.

If you get stuck post your code and a description of the problem and
we'll get you going again.

Good luck!

James Edward Gray II


Logan Capaldo

10/2/2006 3:50:00 PM

0

On Tue, Oct 03, 2006 at 12:17:24AM +0900, Ron Mr. wrote:
> I need to write a script that pulls usernames our of a file that is
> formatted like the following.
>
> "ADLER, CHARLES DAVID" 00-9388 x0753 Engineering
> "ANSELL, ROBERT D" 14-2675 x1624 Sales
> "BIANCHI, CHRISTOPHER" 12-2275 x3280 Marketing
> "CAPOZZI, MICHAEL B" 08-3191 x8035 Manufacturing
>
> The last column is what group the user is in.
> The username needs to be the initials plus the first three letters of
> the group for example...
>
> cdaeng
>
> The GECOS field would be "Charles David Adler 00-9388 x0753 Engineering"
>
> I also need to have it use a default password or "p@ssw0rd!"
>
> Any tips or source code examples would be great, thanks!
>
> --
> Posted via http://www.ruby-....
Hope this helps:

% cat parse.rb
#!/usr/bin/env ruby

DATA.each do |line|
if md = line.match(/^\"([^"]+)\"\s*(.*)$/)
name, remaining_fields = md[1], md[2]
number, extension, group = remaining_fields.split
last_name, first_name, middle_name = name.split(/,?\s+/)
puts "Username: #{first_name[0,1].downcase}#{middle_name.to_s[0,1].downcase}#{last_name[0,1].downcase}#{group[0, 3].downcase}"
nice_name = [first_name, middle_name, last_name].map { |s|
s.to_s.downcase.capitalize }.reject { |s| s == "" }.join(' ')
puts "GECOS: #{nice_name} #{number} #{extension} #{group}"
else
unless line =~ /^\s*$/ # if the line isn't blank, we print an error
STDERR.puts "Warning, mal-formed line: #{line}"
end
end
end

__END__
"ADLER, CHARLES DAVID" 00-9388 x0753 Engineering
"ANSELL, ROBERT D" 14-2675 x1624 Sales
"BIANCHI, CHRISTOPHER" 12-2275 x3280 Marketing
"CAPOZZI, MICHAEL B" 08-3191 x8035 Manufacturing

% ruby parse.rb
Username: cdaeng
GECOS: Charles David Adler 00-9388 x0753 Engineering
Username: rdasal
GECOS: Robert D Ansell 14-2675 x1624 Sales
Username: cbmar
GECOS: Christopher Bianchi 12-2275 x3280 Marketing
Username: mbcman
GECOS: Michael B Capozzi 08-3191 x8035 Manufacturing

jmg3000

10/2/2006 6:02:00 PM

0

On 10/2/06, Logan Capaldo <logancapaldo@gmail.com> wrote:
> On Tue, Oct 03, 2006 at 12:17:24AM +0900, Ron Mr. wrote:
> > I need to write a script that pulls usernames our of a file that is
> > formatted like the following.
> >
> > [snip]
>
> Hope this helps:
>
> % cat parse.rb
> #!/usr/bin/env ruby
>
> DATA.each do |line|
> if md = line.match(/^\"([^"]+)\"\s*(.*)$/)
> name, remaining_fields = md[1], md[2]
> [snip]
>

Just curious, why do you backslash escape the double-quote marks? I
don't think they're special inside a regex, and the match works
without the backslashes.

Logan Capaldo

10/2/2006 8:04:00 PM

0

On Tue, Oct 03, 2006 at 03:02:04AM +0900, John Gabriele wrote:
> Just curious, why do you backslash escape the double-quote marks? I
> don't think they're special inside a regex, and the match works
> without the backslashes.
No good reason, I was fiddling with this while I wrote it, and forgot to
take those out

rpjazzguitar

8/14/2013 6:19:00 PM

0

In bar two, he slides to an Eb on beat one for a quarter. Then slides to D, for a dotted quarter, then eighths of C, A and D,

In bar 3 beat 4 the chord is Am11. He plays F G# B E as 16ths.

Then, bar 4 starts and he plays all 16ths against Esus4 (which I think he plays as 7x775x when he's comping). The notes are A# B E G G# A# B C# E C# E E C# A# Fnat and C#.

So, that's 20 16th notes in a row at a pretty brisk tempo. All Ehw, but not following any common fingering I've seen before. But, given the tempo, I'm thinking he must have practiced this fingering. Does it look familiar to you?

Bar 5 is more pedestrian. Against Am11 it's E C B A D B A G# E D C B

Bar 6 is interesting again. Against Esus4 C E F# G# A B C D D# C G# E B E G# B.


zepa

8/16/2013 8:08:00 PM

0

Hi Rick,
do you have this transcription?
Tks
ZP

Em quarta-feira, 14 de agosto de 2013 15h18min38s UTC-3, rpjazzguitar escreveu:
> In bar two, he slides to an Eb on beat one for a quarter. Then slides to D,
> for a dotted quarter, then eighths of C, A and D, In bar 3 beat 4 the chord
> is Am11. He plays F G# B E as 16ths. Then, bar 4 starts and he plays all
> 16ths against Esus4 (which I think he plays as 7x775x when he's comping).
> The notes are A# B E G G# A# B C# E C# E E C# A# Fnat and C#. So, that's 20
> 16th notes in a row at a pretty brisk tempo. All Ehw, but not following
> any common fingering I've seen before. But, given the tempo, I'm thinking
> he must have practiced this fingering. Does it look familiar to you? Bar 5
> is more pedestrian. Against Am11 it's E C B A D B A G# E D C B Bar 6 is
> interesting again. Against Esus4 C E F# G# A B C D D# C G# E B E G# B.

rpjazzguitar

8/16/2013 10:19:00 PM

0

ZP,

The transcription is on Chico's Facebook page. It's one of the photos.

https://www.facebook.com/pages/Chico-Pinheiro/128133880571790?sk=map&activecategory=Fotos&session_id=...

You may have to befriend Chico to get it.

Danny Green, the San Diego pianist, transcribed it. I think the notes are right, but the time is approximate.


Danny, btw, is a terrific composer and bandleader. He has 2 CD's out as leader, both are excellent -- largely Brazilian influenced music.

Rick

On Friday, August 16, 2013 1:07:31 PM UTC-7, zepa....@gmail.com wrote:
> Hi Rick,
>
> do you have this transcription?
>
> Tks
>
> ZP
>
>
>
> Em quarta-feira, 14 de agosto de 2013 15h18min38s UTC-3, rpjazzguitar escreveu:
>
> > In bar two, he slides to an Eb on beat one for a quarter. Then slides to D,
>
> > for a dotted quarter, then eighths of C, A and D, In bar 3 beat 4 the chord
>
> > is Am11. He plays F G# B E as 16ths. Then, bar 4 starts and he plays all
>
> > 16ths against Esus4 (which I think he plays as 7x775x when he's comping).
>
> > The notes are A# B E G G# A# B C# E C# E E C# A# Fnat and C#. So, that's 20
>
> > 16th notes in a row at a pretty brisk tempo. All Ehw, but not following
>
> > any common fingering I've seen before. But, given the tempo, I'm thinking
>
> > he must have practiced this fingering. Does it look familiar to you? Bar 5
>
> > is more pedestrian. Against Am11 it's E C B A D B A G# E D C B Bar 6 is
>
> > interesting again. Against Esus4 C E F# G# A B C D D# C G# E B E G# B.

zepa

8/18/2013 12:27:00 AM

0

Thanks Rick!
I'm Chico's friend in FB and found the transcription.
I downloaded and I will check it out soon.
Funny enough we will play this tune in a Gig Tuesday.
Better do any kind of analysys after the gig. :-)
To be frank, I don't know exactly what I play over those two chords. I'm sure that I spent some time exploring some alternatives
over the chords when we started playing this tune, but this was a long time ago. At this point I just follow my ears. Very likely I'm play something obvious;
the chord tone plus chromatizations all along the sequence.
Also, we improvise over the whole progression. I've never heard Chico playing this instrumental, but I assume he should do the same (with
the vocals his solos are short and only over "A").
The only thing I remember is that I've never considered Ewh over Esus, because we have been using Esus7(9) since the very beginning.
After this gig, it might be good explore other options.

Thanks again!
ZP

rpjazzguitar

8/18/2013 1:10:00 AM

0

Zepa, glad you got it!

I found an error in the transcription. Solo 1, bar 5, beat 4, that's a C# not a C natural. It's a lot easier to play that way. I think he starts bar 5 with his first finger on the G string, fret 9. Then catches the C with his second finger, the B with his first finger and then slides to the A with the first finger (I can hear the slide on the recording). He flattens the first finger to catch the D. At that point he can finish the bar at the 6th fret (notice that it really helps that the next to last note is a C# (against an Am11!) not a C). He plays the last note of the bar with his pinkie and slides it up a fret to begin bar 6.

There may be another C# in bar 7 beat one, but frankly, it's hard to hear.

Please, let me know if you can figure out what he was practicing to be able to improvise this -- and at such a high tempo.

One thing that's interesting about the Ehw. In bar 4, beat 4, he plays C#, A# F and C#. That's a descending Bbm triad. It is within Ehw. But, it is also a half step up from the chord that he's moving to in the next beat -- in essence sliding from Bbm to Am.

This is something I've noticed about him before. You analyze one of his lines and it makes logical sense in more than one way.

For example, in his Tempestade solo he plays two notes a fourth apart low to high. Then he plays the two notes a minor third down this time, high to low. He keeps on like that, dropping minor thirds and changing which one he plays first.
When you look at the transcription you see that it's a diminished scale, it's also a two note pattern descending in thirds and, along the way, he hits a bunch of different triads within the diminished scale. I end up wondering, does he just hear this? Is he thinking consciously of all of that at once? Or maybe just one of the ideas and the others are sort of happy accidents? And then, you have to consider the tempos he does this stuff at.

The more I study him, the more I am in awe.

Rick



simonblack

8/18/2013 10:05:00 PM

0

On Saturday, August 17, 2013 6:09:48 PM UTC-7, rpjazzguitar wrote:
> Zepa, glad you got it!
>
>
>
> I found an error in the transcription. Solo 1, bar 5, beat 4, that's a C# not a C natural. It's a lot easier to play that way. I think he starts bar 5 with his first finger on the G string, fret 9. Then catches the C with his second finger, the B with his first finger and then slides to the A with the first finger (I can hear the slide on the recording). He flattens the first finger to catch the D. At that point he can finish the bar at the 6th fret (notice that it really helps that the next to last note is a C# (against an Am11!) not a C). He plays the last note of the bar with his pinkie and slides it up a fret to begin bar 6.
>
>
>
> There may be another C# in bar 7 beat one, but frankly, it's hard to hear..
>
>
>
> Please, let me know if you can figure out what he was practicing to be able to improvise this -- and at such a high tempo.
>
>
>
> One thing that's interesting about the Ehw. In bar 4, beat 4, he plays C#, A# F and C#. That's a descending Bbm triad. It is within Ehw. But, it is also a half step up from the chord that he's moving to in the next beat -- in essence sliding from Bbm to Am.
>
>
>
> This is something I've noticed about him before. You analyze one of his lines and it makes logical sense in more than one way.
>
>
>
> For example, in his Tempestade solo he plays two notes a fourth apart low to high. Then he plays the two notes a minor third down this time, high to low. He keeps on like that, dropping minor thirds and changing which one he plays first.
>
> When you look at the transcription you see that it's a diminished scale, it's also a two note pattern descending in thirds and, along the way, he hits a bunch of different triads within the diminished scale. I end up wondering, does he just hear this? Is he thinking consciously of all of that at once? Or maybe just one of the ideas and the others are sort of happy accidents? And then, you have to consider the tempos he does this stuff at.
>
>
>
> The more I study him, the more I am in awe.
>
>
>
> Rick

Good point. I believe that he hears it and falls into a groove with it: no thinking. Uses his ear, no question about it. The underlying skills and knowledge are the base of course, as always. But the academia is pointless to study after the improv, except in the academic framework of learning. Pros hear all of it. It is just like Charlie Parker said: "Learn music. Learn your instrument well. Then just blow." The thought process is purely academic and secondary to augmented audio-cognition mental activity (the ear). The latter being art. The ear is primary. It is trancelike and meditative in nature and not math. It is beyond the notes. It can be expanded too, far beyond normal cognition and appearance making. The eye for example sees nothing. The science says that the eye is a device that sends electrical pulses to the brain that are crude and meaningless in and of themselves. It is the brain that creates the appearances. Same thing with the ear.

One fact about the ear: you've got to have it, some kind of ear, before ever learning the math. Otherwise music is not your gig. Studying music at CUNY I saw that everyday. Go to the board and write the notes on the board, first note is F. Teacher plays F dominant scale and only 2 out of 20 people in the entire class put a flat next to the E. Then after 2 years of pounding ear training (like 3 classes a day: one self study on keys, another on instrument, and the third on dictation and transcription) only a handful of people make it to the third year. Of course they all got straight A in theory because it is thinking, nothing more easy. But no ear means no degree. It became very clear that some have it and some do not: the ear. Ear Master 6 is a great app. for expanding the ear. It even teaches sight reading. I pound on that every night now instead of my wife. LOL.

Sorry for the rant.

SB