in reply to Re^2: FEAR OF PERL
in thread FEAR OF PERL

(i need perl in scripting to help me to write scripts to administarte linux ,, and to working with itis configuration files

What exactly are you trying to do now?

There are good references all over the net, e.g.:

* Automating UNIX system administration with Perl
* Linux System Administration and Configuration

and books:

* Automating UNIX and Linux Administration (not only w/Perl)

But there are zillions more. How about to formulate *one* *small* problem first, which we may try to solve together?

mwa

Replies are listed 'Best First'.
Re^4: FEAR OF PERL
by firewall00 (Acolyte) on Oct 14, 2007 at 12:42 UTC
    i had some problems and i posted all of it here like how to comment line in named.conf file and i felt my self dummy :S
    cuz of my frequently asked questions in the same thread
    but what i want to do is to managing linux and servers by perl like editing in itis configuration file
    like adding a domain in the named file and create the zone file in /var/named
    adding virual host to apache httpd.conf file
    and various type of linux administration

    thanks for your great support

      adding a domain in the named file and create the zone file in /var/named
      I'm not sure how sophisticated you are in
      administrating this stuff *at all* (without Perl).
      There is something out there that describes
      how to handle complicated things in the zone files,
      eg. Format of DNS files.

      Adding or modifying something depends IMHO entirely
      on the conventions already used on your server (what only you may know).
      adding virtual host to apache httpd.conf file
      This is the same like above. Normally, you won't "add"
      anything to "httpd.conf", but rather let include "httpd.conf"
      subdirectories containing configuration files, like this
      [httpd.conf] example piece:
      ...
      Include /etc/apache2/vhosts-batch-01/*.conf
      Include /etc/apache2/vhosts-batch-02/*.conf
      ...
      In these directories, you may provide specialized
      configuration files (xyz123.conf) for any http service you provide.
      In each directory you may have some "common.inc" file
      which gets included by each .conf in the respective directory

      But that's the Black Art of Apache Configuration and
      this hasn't very much to do with Perl in the first place.
      Once you are able to create a consistent multihost
      configuration at all, there should be no problem to
      write some Perl-Scripts that may manage them

      Regards

      mwa
        thanks mwa and thanks for you tips also
        iam now having a problem and i think it's stupidness to have such one
        i posts some posts about how to comment zones in the zone file and i got a wonderful answers and a good code especially from shmem
        by the way here is the code shmem wrote
        #!/usr/bin/perl -w use strict; print " please enter the domain name: "; my $targetdomain = <STDIN>; chomp $targetdomain; my $file = "/home/blackice/hello"; rename $file, "$file.bak" or die "Can't rename file '$file': $!\n"; open my $in, '<', "$file.bak" or die "Can't read file '$file': $!\n"; open my $out, '>', $file or die "Can't write file '$file': $!\n"; my $comment = 0; my $block = 0; while(<$in>) { if (/^zone\s+"$targetdomain"/) { $comment++; $block += () = /(\{)/g; print $out '// '.$_; next; } if($comment) { $block += () = /(\{)/g; s!^!// ! if $comment or $block; $block -= () = /(\})/g; $comment = 0 unless $block; } print $out $_; }

        and it works very well and i understand the way of that script works and it was agood idea
        but i want to add some feature to this script i want to add the date at the top of the zone when that zone was commented on
        i have tried to make some tries ,, i have creates my $date = `date -u "+%m/%d/%Y %H:%M:%S"`; this is a date string that i can print in the script and i tried to print it here
        print "date"; print $out $_;

        also i have tried to print it before this line  print $out '// '.$_; next; but it failed ,, i also have tried to print it in some other places and it also fails
        so can you help me of how to think about that

        thanks