Friday, 15 March 2019

Perl Script to used to validate the IP address




sub ValidateIPAddress
  {
     my $ip=trim(<inputIP>);

     if( $ip=~ m/^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)$/ && ( $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255))
   {   
         return 1;
       }
elsif($ip=~ m/^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\s+(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)$/ && ( $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255 && $5 == 255 && $6 == 255 && $7 == 255 && $8 == 255))
   {
     return 1;
   }
elsif($ip=~ m/^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\/([0-9]{1,2})$/ && ( $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255 && $5 == 32))
   {   
         return 1;
       }
  else
   {
     return -1;
   }
  }

perl script removes the unnecessary leading and trailing commas from the input provided



sub Fuctionname
  {
    my $temp=trim(<input>);

$temp=~s/^\,|\,$//g;
$temp=~s/,+/\,/g;

return $temp;
  }

Tuesday, 12 March 2019

Top 10 Machine learning python packages

Numpy
Scipy
Pandas
Matplotlib
Scikit-learn
Six
Tensorflow
Requests
Python-dateutil
Pytz

Friday, 22 February 2019

compare two different paragraph line by line in Python


from difflib import HtmlDiff

text_A= """
1) line number 1
2) line number 2
3) line number n
"""

text_B= """
2) line number 2
3) line number n
4) line number raghu
"""




delta_html = HtmlDiff().make_file(text_A.splitlines(),
                                  text_B.splitlines())

with open('diff.html', 'w') as f:
     f.write(delta_html)

Thursday, 21 February 2019

compare two different files line by line in Python

import difflib
from difflib import HtmlDiff


with open('show_run_SW-VSS_2019-02-05.txt') as f1:
    f1_text = f1.read()
with open('show_run_SW-VSS_2019-02-01.txt') as f2:
    f2_text = f2.read()



delta_html = HtmlDiff().make_file(f1_text.splitlines(),
                                  f2_text.splitlines())

with open('diff22.html', 'w') as f:
     f.write(delta_html)

Tuesday, 19 February 2019

mongo db query ( group , aggregate ) to fetch latest network backup




 db.backup.aggregate({$unwind: '$backupDoc'},{$match: { "backupDoc.status": "success" }},{$group: {"_id" : "$deviceIp",lastdate: {$max: "$backupDoc.datetime"}}

Saturday, 9 February 2019

Checking Firewall Status and Stopping Firewall in centos



[root@DSCenWeb01 ~]# sudo firewall-cmd --state
running
[root@DSCenWeb01 ~]# sudo systemctl stop firewalld

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...