Thursday, 10 October 2019

how many ways to create file using perl?

Method 1:

open(FHE,">file1.txt");


Method 2:

readpipe( "touch kkm.txt" );


Method 3:

system("touch kkm.txt");


Method 4:

open(my $file, '|-', "touch kkm.txt");


Method 5:

 `touch kkp.txt`;


Method 6:

qx/touch kkm.txt/;


Method 7:[always execute exec at eof]

exec("touch kkm.txt");


Method 8:

readpipe( "echo  > file1.txt" );


Method 9:

system("echo  > file2.txt");


Method 10:

`echo  > file3.txt`;


Method 11:

qx/echo  > file4.txt/;


Method 12:

open(my $file, '|-', "echo  > file5.txt");


Method 13:[always execute exec at eof]

exec("echo  > file6.txt");


Method 14:

readpipe( "cat '' > cat1111.txt" );


Method 15:

system("cat '' > cat1112.txt");


Method 16:

`cat '' > cat1113.txt`;


Method 17:

qx/cat '' > cat1114.txt/;


Method 18:

open(my $file, '|-', "cat '' > cat1115.txt");


Method 19:[always execute exec at eof]

exec("cat '' > cat1116.txt");


Method 20:

readpipe( "print  > cat1111.txt" );


Method 21:

system("print  > cat1112.txt");


Method 22:

`print  > cat1113.txt`;


Method 23:

qx/print > cat1114.txt/;


Method 24:

open(my $file, '|-', "print  > cat1115.txt");


Method 25:[always execute exec at eof]

exec("print  > cat1116.txt");


Method 26:[always execute exec at eof]

exec "vim   >  file.txt";

Kill process by using any one kill command

pkill vim;


Method 27:[always execute exec at eof]

exec "vi  >  file.txt";

Kill process by using any one kill command

pkill vi;


Method 28:[always execute exec at eof]

exec "nano  >  file.txt";

Kill process by using any one kill command

pkill nano;


Tuesday, 3 September 2024

How to Call Shell Commands from Ruby: A Comprehensive Guide

In Ruby, interacting with the system shell is straightforward, allowing you to execute commands, capture output, and handle errors efficiently. Whether you’re automating tasks, running scripts, or managing system operations, Ruby offers multiple ways to interact with the shell. In this guide, we’ll explore various methods to call shell commands from within a Ruby program and how to handle their outputs and errors.

1. Using Backticks (`command`)

The simplest way to execute a shell command in Ruby is by using backticks. This method runs the command in a subshell and returns its standard output as a string.

output = `echo 'Hello, World!'`
puts output
Read more »

Labels:

Thursday, 21 March 2024

Troubleshoot Application Failures with Kubernetes!


 In the dynamic world of containerized applications, where Kubernetes reigns as the orchestrator of choice, encountering issues is not uncommon. Whether it’s a pod failing to start, a service unreachable, or unexpected behavior within your cluster, efficient troubleshooting is crucial to maintain the reliability and performance of your applications. In this guide, we’ll explore some essential techniques and tools to diagnose and resolve common problems in Kubernetes.

Read more »

Labels:

Tuesday, 29 April 2025

How to Add HTML and CSS to a PDF in PHP

If you’re looking to convert an HTML page with CSS into a PDF document, there are several tools and libraries available. Depending on your project’s requirements, you may choose a library that fits your needs in terms of speed, compatibility with CSS, or ease of integration into your PHP application.

This blog post will cover some popular tools for converting HTML and CSS into PDF using PHP, including solutions like wkhtmltopdf, mPDF, and more.

Read more »

Labels:

Thursday, 13 March 2025

Can you write docker file to install nodejs application - explanation with the best practices.

In the era of cloud-native development, Docker has revolutionized how applications are built, shipped, and deployed. For Node.js developers, containerization offers a consistent environment across development, testing, and production, eliminating the infamous “it works on my machine” dilemma. However, crafting an efficient and secure Dockerfile for Node.js requires more than just basic syntax—it demands adherence to best practices that optimize performance, enhance security, and ensure maintainability.

This guide will walk you through creating a production-grade Dockerfile for Node.js applications, explaining every decision in detail. By the end, you’ll understand not just the “how” but the “why” behind each best practice, empowering you to build robust, scalable, and secure containers.

Table of Contents

  1. What is a Dockerfile?
  2. Why Docker for Node.js?
  3. Step-by-Step Dockerfile Creation
    • Choosing the Base Image
    • Setting the Working Directory
    • Copying Package Files
    • Installing Dependencies
    • Copying Application Code
    • Exposing Ports
    • Defining the Runtime Command
  4. Best Practices Deep Dive
    • Multi-Stage Builds
    • Non-Root User & Permissions
    • Environment Variables
    • Process Managers (PM2)
    • Healthchecks
    • Logging to Stdout/Stderr
    • Security Scans
    • Image Tagging
  5. Complete Dockerfile Example
Read more »

Labels:

Tuesday, 16 July 2024

Crafting an Interactive Real-Time Countdown with User Input in Bash


 In this post, we explore a practical application of Bash scripting for creating an interactive real-time countdown that also incorporates user input. The idea is to present a series of questions from a file with a countdown for each, prompting the user to respond within a specified time limit. This script can be useful for quiz applications or timed tests.

Problem Statement

The task is to display a countdown timer alongside questions from a text file (QuestionBank.txt). The user has a fixed amount of time to answer each question before the script automatically proceeds to the next one. The challenge lies in managing the timer and user input simultaneously without cluttering the terminal output.

Read more »

Labels:

Monday, 18 March 2024

Essential Kubectl Commands for Every DevOps Engineer


 As the complexity of software development grows, so does the need for efficient and reliable deployment solutions. Kubernetes, an open-source platform designed to automate deploying, scaling, and operating application containers, has become the go-to solution for managing containerized applications. However, navigating through Kubernetes’ vast functionalities can be daunting for many, especially for DevOps engineers tasked with maintaining the health and performance of applications. This is where kubectl, Kubernetes’ command-line tool, becomes invaluable.

Read more »

Labels:

Sunday, 1 December 2024

Essential Kubernetes Commands with Simple Explanations

 Kubernetes, or K8s, is a leading container orchestration platform that simplifies the deployment and management of applications. Knowing the right commands is key to navigating Kubernetes effectively. Here’s a guide to important Kubernetes commands explained in simple terms.

1. kubectl version

Command:

kubectl version --short

This command shows the versions of both the client and server components of Kubernetes. It helps ensure your kubectl tool is compatible with the cluster.

Read more »

Labels: