python

prompt and read input variables from keyboard

Let’s find how to prompt and read input variables from keyboard while executing a script using shell, perl, python, batch and powershell (windows and Linux)

  • On Linux via shell

    read -p “Enter your name: ” name
    echo “Hi, $name. Let’s be friend!”

  • On Windows via powershell

    $name=read-host “Enter your name:”
    write-host “Hi $name, Let’s be friend!”

  • On Windows via batch

    Set /p Name=”Enter your name:”
    echo “Hi %name%, Let’s be friend!”

  • On Windows or Linux via perl

    print “Enter your name “;
    my $name = ;
    chomp $name; # Get rid of newline character at the end
    print “Hello $name, let’s be friend”;

  • On Windows or Linux via python

    name=input(“Enter your name: “)
    print (“Hello ” + name + ” let’s be friend”)

Etienne Noumen

Sports Lover, Linux guru, Engineer, Entrepreneur & Family Man.

Recent Posts

The Importance of Giving Constructive Feedback

Offering employees, coworkers, teammates, and students constructive feedback is a vital part of growth on…

2 days ago

Why Millennials Need To Invest for Retirement Now

Millennials should avoid delaying the inevitable and look into various retirement investment pathways. Here’s why…

2 days ago

A Daily Chronicle of AI Innovations in May 2024

AI Innovations in May 2024

5 days ago

Tips for Ensuring Success Throughout Your Career

For most people, a satisfactory career is essential for leading a happy life. However, ensuring…

1 week ago

Different Career Paths in the Pipeline Industry

The pipeline industry is more than pipework and construction, and we explore those details in…

1 week ago

SQL Interview Questions and Answers

SQL Interview Questions and Answers In the world of data-driven decision-making, SQL (Structured Query Language)…

2 weeks ago