Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, how can I parse crontab output into a csv format?

Replies are listed 'Best First'.
Re: parsing crontab output
by matija (Priest) on Apr 09, 2004 at 15:43 UTC
    Something like this, perhaps?
    #!/usr/bin/perl -w my $crontab=`crontab -l`; foreach (split(/\n/,$crontab)) { next if /^#/; my @arr=split(/\s+/,$_); $arr[5]=join(" ",splice(@arr,5)); # join the command line into a sin +gle element @arr=map(/,/?"\"$_\"":$_,@arr); # quote fields with commas print join(",",@arr)."\n"; }
    This code has been tested, but not on animals.
      thank you very much for your quick response. this is very helpful
Re: parsing crontab output
by flyingmoose (Priest) on Apr 09, 2004 at 18:24 UTC
    Rather than handrolling this, you might be interested in a few CPAN modules. Search CPAN for "crontab" -- looks like lots of good stuff there.
Re: parsing crontab output
by jmcnamara (Monsignor) on Apr 09, 2004 at 18:40 UTC

    Not exactly what you are asking for but it may give you some ideas, Sean Burke's crontab2english.

    --
    John.