On Mon, 8 Sep 2003, Adam Hewitt wrote:

> I have a file which has lines in it like the following:
> 
> username1,password1,7200,10800
> username2,password2,7200,10800
> username3,password3,10800,10800
> 
> etc...and I need to turn the file into this:
> 
> username1     Password = "password1"
>       Idle-Timeout = 7200,
>       Session-Timeout = 10800,
>       Failover = 1

Heh .. I've often had to write something that does the reverse, i.e.
Radius format ==> CSV. 

Here is a perl one-liner that reads the user records from STDIN:

perl -n -e 'chomp; @a=split/,/; print qq{$a[0]       Password = "$a[1]"\n        
Idle-Timeout = $a[2],\n        Session-Timeout = $a[3],\n        Failover = 1\n\n}'

((not a recommended programming practice!))

cheers
rickw


---------------------------------------------
Rick Welykochy || Praxis Services Pty Limited

"Every program attempts to expand until it can read mail. Those programs
 which cannot so expand are replaced by ones which can."
     -- Jamie Zawinski, the Law of Software Envelopment

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to