Saturday, 31 December 2022

How to get the absolute path of running perl script?


Method1:
 
use File::Basename;
my $dirname = dirname(__FILE__);

Method2:
 
use Cwd 'abs_path';
print abs_path($0);

Method3:
 
if ENV is defined then
$ENV{SCRIPT};

Labels: , , , , ,

Automate Linux SysAdmin tasks with Ansible in 95+ examples - part 1



1. Decrypting an Ansible Vault

You have an Ansible Vault-encrypted file and need to decrypt it to access the secrets.

ansible-vault decrypt secret_file.yml

Ansible will prompt you for the Vault password used to encrypt the file.You can now access the decrypted data in secret_file.yml.

2.Using Ansible Vault in Ansible Playbooks

---
- name: Example Playbook
  hosts: localhost
  vars:
    sensitive_data: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      66366232396135343865393765653837646562306361623863343535333563373362393865393338

You can create this encrypted variable using ansible-vault encrypt_string.

3.Checking Out Git Repositories via HTTPS with Ansible

You need to automate the process of checking out a Git repository hosted on HTTPS using Ansible.

Create a Playbook to Clone the Git Repository
Read more »

Labels: , ,

Friday, 30 December 2022

Python XML File parsing Tutorial - Best Practices

Hi, Today Article we demonstrates, how to work with XML files using the lxml library. The project covers a range of common XML processing tasks, 

including parsing, modifying, validating, converting, searching, transforming, generating, updating, deleting, handling namespaces, and more. 

The lxml library is a popular and powerful Python library for working with XML files. It provides fast and efficient parsing, XPath and XSLT support, and many other features that make it a great choice for processing XML in Python. 

By following the examples and techniques shown in this project, you can learn how to use lxml to handle complex XML files and automate tasks in your Python projects.

Also we start by demonstrating how to parse an XML file using the etree.parse() function. We show how to access the root element of the parsed tree and how to traverse the tree to access its nodes and attributes.

Read more »

Labels: , ,

Wednesday, 28 December 2022

The Importance of Local SEO for Small Businesses

As a small business owner, you may think that search engine optimization (SEO) is only for large corporations with big marketing budgets. However, local SEO is a powerful tool for small businesses to increase their visibility and attract local customers. In this blog post, we'll explore the importance of local SEO for small businesses and provide tips on how to improve your local search engine ranking.

Read more »

Labels: ,

Tuesday, 27 December 2022

How can we get name of running Perl script?


Method1: 

running script can be found using $0 variable
print $0;

Method2: 

print __FILE__;

Method3:

use File::Basename;
my $name = basename($0);

Labels: , , ,

Wednesday, 21 December 2022

Top 10 programming Languages for Artificial Intelligence in 2023

Artificial Intelligence (AI) has become a rapidly growing field in the world of computer science, and many programming languages are being used to develop AI applications. As we approach 2023, it's important to stay updated on the latest programming languages that are popular for AI development. In this article, we'll discuss the top 10 programming languages for Artificial Intelligence in 2023 and their benefits.

Read more »

Labels: , ,

Monday, 19 December 2022

How many ways to compare two strings in perl?

Method 1:

cmp - Compare

Method 2:

eq - Equal to

Method 3:

ne - Not-Equal to

Method 4:

Lt - Less than

Method 5:

le - Less than or equal to

Method 6:

gt - Greater than

Method 7:

ge - Greater than or equal to

Labels: , , , , , ,

Friday, 16 December 2022

What is the use of file test operator in perl?

 Method1:

 print "file exists!\n" if -e $base_path;

Method2: 

print " it is a plain file!\n" if -f $base_path;

Labels:

Friday, 9 December 2022

how to print the contents of perl hash?

 

Method1

 print "$_ $h{$_}\n" for (keys %h);


Method2:
 
while (my ($k,$v)=each %h){print "$k $v\n"}

Method3:
 
print "@{[%hash]}";

Method4:
 
print map { "$_ $h{$_}\n" } keys %h;

Method5:
 
print "$_ $h{$_}\n" for keys %h

Method6:
 
foreach(keys %my_hash) { print "$_ / $my_hash{$_}\n"; }

Method7:
 
map {print "$_ / $my_hash{$_}\n"; } keys %my_hash;

Method8:
 
print map {$_ . " "} %h, "\n";

Labels: , ,

Wednesday, 7 December 2022

Amazon Web Services Certforall Saa-C03 Vce Download 2022-Dec-27 by Martin 138q Vce

QUESTION 1

A company needs guaranteed Amazon EC2 capacity in three specific Availability Zones in a specific AWS Region for an upcoming event that will last 1 week.

What should the company do to guarantee the EC2 capacity?

A. Purchase Reserved instances that specify the Region needed

B. Create an On Demand Capacity Reservation that specifies the Region needed

C. Purchase Reserved instances that specify the Region and three Availability Zones needed

D. Create an On-Demand Capacity Reservation that specifies the Region and three Availability Zones needed

Answer: D

Explanation: 

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-capacity-reservations.html: "When you create a Capacity Reservation, you specify:

The Availability Zone in which to reserve the capacity"

-------------------------------------------------------------------------------------------------------------------

Read more »

Labels: ,