Operating System - HP-UX
1748289 Members
3324 Online
108761 Solutions
New Discussion юеВ

Re: Radius - File to Mysql Migration

 
SOLVED
Go to solution
rmueller58
Valued Contributor

Radius - File to Mysql Migration

Have a radius users file, I need to parse and reformat into a CSV file to insert into the userinfo table 

 

Each record in the file is two lines.

 

0011aa22b3cc    Auth-Type := Local,     User-Password == "0011aa22b3cc "
#Jane Doe Dell_D820

Radius requires the MAC to be in 00:00:00:00:00:00

 

and I need to get the second line into the same line position

 

I was attempting to use Awk with a substr substittution on the MAC but I am failing miserably.

 

We are in process of attempting to migrate from a very old revision of freeradius to one that runs under a mysql database.

 

Any suggestions appreciates..

7 REPLIES 7
James R. Ferguson
Acclaimed Contributor
Solution

Re: Radius - File to Mysql Migration

Hi:

 

See if this little bit of Perl helps you:

 

# cat ./format
#!/usr/bin/perl use strict; use warnings; while (<>) { chomp; $_ .= q( ) . <> unless eof; my @F = split; my @m = unpack("a2"x6,$F[0]); $F[0] = sprintf join ":", @m; print "@F\n"; } 1;

Run as:

 

# ./format file

 Regards!

 

...JRF...

rmueller58
Valued Contributor

Re: Radius - File to Mysql Migration

Thanks James.

 

 

rmueller58
Valued Contributor

Re: Radius - File to Mysql Migration

James,

I am getting an error when running. Any suggestions? 

 

./reformat: line 5: syntax error near unexpected token `)'
./reformat: line 5: `while (<>) {'

 

rmueller58
Valued Contributor

Re: Radius - File to Mysql Migration

Disregard, I forgot to put #!/usr/bin/perl at top line. Fixed.

James R. Ferguson
Acclaimed Contributor

Re: Radius - File to Mysql Migration


@rmueller58 wrote:

Disregard, I forgot to put #!/usr/bin/perl at top line. Fixed.


Yes, that would cause the shell to try an interpret it :-)

 

Does this do what you need?

 

Regards!

 

...JRF...

rmueller58
Valued Contributor

Re: Radius - File to Mysql Migration

James, did the trick,

Now I need to get create CSV record to import. I think can go from here.

 

Thanks again,

 

the new forum interface is a bit intimidating for some reason. Guess I've not been on for quite a while.

 

Kudos to JRF.

James R. Ferguson
Acclaimed Contributor

Re: Radius - File to Mysql Migration


@rmueller58 wrote:

James, did the trick

 

Kudos to JRF.


To assign those, see:

 

http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/kudos#kudos

 

and, since marking a post "solved" doesn't assign kudos, but is of great value, too:

 

http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/solutions#solutions

 

Regards!

 

...JRF...