Shell Scripting - User Input & Comments

HackerSploit · Intermediate ·📰 AI News & Updates ·7y ago

Key Takeaways

This video series by HackerSploit covers the basics of shell scripting, including user input and comments, using tools like Sublime Text and Terminal, and demonstrating techniques such as using the `read` command and `echo` statement to handle user input and print output.

Full Transcript

[Laughter] [Music] hey guys hackersploit here back again with another video and welcome back to the shell scripting course or series and in this video we're going to be looking at user input and comments all right so comments is something that's really really simple to understand and i thought why not cover it with user input all right so before we get started i just want to let you guys know that before i you know go into showing you guys any script as many of you were requesting for you guys need to understand shell scripting first and i can do that before i touch on functions now again i am going to be showing you different scripts that are in line with you know penetration testing ethical hacking but we'll get to that slowly as we move along for now let's just try and get to know the essentials now when we talk about user input uh it's something that's really really simple and and as i said with shell scripting it becomes really intuitive as you move along so that everything kind of makes sense and you'll find yourself really not struggling with the syntax once you once you know uh or once you get used to it all right so the the syntax for uh for essentially accepting user input when we're talking about simply just reading in data in the form of keyboard input or input from a variable now of course we're going to be touching upon standard input which is something that most of you are accustomed to if have been doing c or c plus plus and you are and you understand the different types of input and how they are standardized but for this case let's focus on read all right so the syntax is quite simple now let me just uh come over here in my sublime text and i type in read all right so that is the syntax now what comes after read is really really important because they said you can prompt you can prompt user input from the keyboard or through a variable but you need to specify a variable to the read now let me uh let me just make this really really simple so i'm going to just create a simple script that will uh that will ask you for maybe your your name or your favorite spot some or something like that and then it's going to print it out all right quite simple so to do that i'm going to say read and then i'm going to also bring up a prompt all right so a prompt here will essentially prompt data to the user or information that you want the user to know before they enter in their data so i can say prompt that is denoted by a p a uh a dash p as you can see all in lowercase and then after this is where i put in my prompt so i can say um enter your um enter your uh let's see enter your name or something like that something really simple and then after the prompt or you can give that a space that's good practice so after this after the after the space and after the prompt this is when you enter the variable in which you want to store this data in remember i told you you can store data in variables as you probably already know and now we have to declare our variable so i'm just going to call this variable name all right and that's simply the syntax so let me just explain this before we move any further so to read input from a keyboard or a variable we can say read all right and then we select the prompt here the prompt can be used or not used and i'll show you how to do how to go above how to go about using both all right so the prompt here and then you have the prompt itself which is essentially asking the user to enter their name and then this data is going to be stored in the variable name so then we can call from this variable and say echo and remember we use the dollar sign and the variable to call it out but we can say something like uh something like your name is and we just close that up and that's going to print it out in a sentence all right so what i'm going to do is i'm going to save this script and let me just go into my terminal i've already executed the permissions i've already given it permissions so all i have to do is uh i can just let me list the files in here all right so it's input so input dot sh and i'm going to hit enter and you see it's going to prompt you to enter your name so i'm going to enter my name as alexis and i'm going to hit enter and there you are it's going to say your name is alexis fantastic really nothing special about that script it's a pretty pretty basic it's simply taking in data uh that you've entered and it's outputting the data now there is something really really awesome that you can do with variables and especially user input when you talk about shell scripting and that is simply uh storing as many variables as you like in the types of data that you're going to be entering let me give you a simple example let's say i wanted to enter my full name well i could use one variable or let's say i wanted to store additional information so um let's say uh and actually we can start using our comments so to to to enter a comment in uh in shell scripting you simply use the uh the bang sign or the hash whatever you want to call it so we're going to call this uh user oops sorry user input and um there you are all right so that's simply a comment really nothing complicated about that so now let's say we wanted now the user to enter their full name well how would we go about doing this and this will explain a lot of what i've been talking about all right so we are now going to be saying uh let's let's give the user a prompt but in a different way we're going to say please enter your full name and remember we want to store each name in its own type in its own variable so that we can manipulate the data when we talk about printing it or saving it in a database okay so echo please enter your full name now we can essentially we're essentially asking the user to enter their full name so let's make this a bit more presentable and now we need to use the read command to accept the data that is being inputted but we need to store it in different variables now the variable that i'm going to be using is first name and last name and again feel free to customize the variable names to whatever you feel is appropriate okay so there we are read first name and last name now we can essentially just print out the data so we can say your name is and simply just use the variables but now we separate them so first name and last name pretty cool right now you'll see how awesome this is and how versatile uh the uh the shell scripting can be so let me just show you that right now so if i go back into my terminal and i launched that script again see it's gonna ask me to enter my full name so i can type in for example um let's see let's get a good name here um we can just say john and john doe some something something really really simple and we hit enter and there you are it's going to print out the data like that now the thing about uh splitting up the data inputted into different variables is it gives you versatility in the in the sense that you can control the data that was inputted to you now for example if you wanted the user to input their name and their age it can also do that as well and you can simply just customize it to what you want please enter your your name we can just say your name and your age and your age right and we can change this variable name to age and that will print it out and then we can simply just remove that and put our age in here and you can say your name is and you are um we can say eight years old all right so something really really simple like that and you get how this can be manipulated to fit or to suit your needs and of course when you're storing this data remember presentation in in terms of how you store the data is extremely important as well so input.s8 please enter your name i can say alexis and i can type in an age of 45 for example and there you are you now from here you can see what separates shell scripting from other scripting or programming languages in its in the way it is versatile in accepting data printing out data and also storing data we'll be looking at functions for loops all that good stuff and how to manipulate data and of course as i mentioned we'll be taking a look in between as we move along at different cool scripts that you can create in relation to ethical hacking and penetration testing all right so that is going to be it for this video guys in this video we talked about uh accepting user input and comments something really really simple but now that you know how to do it uh you know you you simply now are a step ahead and yeah we're gonna be taking a look now at functions and then conditional statements etc all right so that's gonna be it for this video guys if you like this video found value in it please leave a like down below if you have any questions or suggestions let me know in the comments section on my social networks or on my website and i'll be seeing you in the next video peace [Music] you

Original Description

Hey guys! HackerSploit here back again with another video, in this series we will be looking at how to create shell scripts. A shell script is a computer program designed to be run by the Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages ⭐Help Support HackerSploit by using the following links: 🔗 NordVPN: https://nordvpn.org/hacker Use the link above or the code below for 77% Off your order Promo Code: hacker Patreon: http://patreon.com/hackersploit I Hope you enjoy/enjoyed the video. If you have any questions or suggestions feel free to ask them in the comments section or on my social networks. 🔗 HackerSploit Website: https://hsploit.com/ 🔗 HackerSploit Android App: https://play.google.com/store/apps/details?id=com.hsploitnews.hsploit&hl=en 🔹 Support The Channel NordVPN Affiliate Link: https://nordvpn.org/hacker Patreon: http://patreon.com/hackersploit 🔹 Get Our Courses Get a special discount on our courses: The Complete Deep Web Course 2018: https://www.udemy.com/the-complete-deep-web-course-2017/?couponCode=DWCBP2017 🔹 SOCIAL NETWORKS - Connect With Us! ------------------------------- Facebook: https://www.facebook.com/HackerSploit/ Twitter: https://twitter.com/HackerSploit Patreon: http://patreon.com/hackersploit -------------------------------- Thanks for watching! Благодаря за гледането Kiitos katsomisesta 感谢您观看 Merci d'avoir regardé Grazie per la visione Gracias por ver شكرا للمشاهدة دیکھنے کے لیے شکریہ देखने के लिए धन्यवाद
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from HackerSploit · HackerSploit · 0 of 60

← Previous Next →
1 How To Install Kali Linux 2.0 On Virtual Box
How To Install Kali Linux 2.0 On Virtual Box
HackerSploit
2 100 Subscriber Q&A! - How I Learned Ethical Hacking
100 Subscriber Q&A! - How I Learned Ethical Hacking
HackerSploit
3 BlackArch Linux Review - Better Than Kali Linux?
BlackArch Linux Review - Better Than Kali Linux?
HackerSploit
4 How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
HackerSploit
5 Wireshark Tutorial for Beginners - Installation
Wireshark Tutorial for Beginners - Installation
HackerSploit
6 Wireshark Tutorial for Beginners - Overview of the environment
Wireshark Tutorial for Beginners - Overview of the environment
HackerSploit
7 Wireshark Tutorial for Beginners - Capture options
Wireshark Tutorial for Beginners - Capture options
HackerSploit
8 Wireshark Tutorial for Beginners - Filters
Wireshark Tutorial for Beginners - Filters
HackerSploit
9 Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
HackerSploit
10 Complete Ethical Hacking Course #2 - Installing Kali Linux
Complete Ethical Hacking Course #2 - Installing Kali Linux
HackerSploit
11 Parrot OS 3.5 Review | The Best Kali Linux Alternative
Parrot OS 3.5 Review | The Best Kali Linux Alternative
HackerSploit
12 Nmap Tutorial For Beginners - 1 - What is Nmap?
Nmap Tutorial For Beginners - 1 - What is Nmap?
HackerSploit
13 Katoolin | How To Install Pentesting Tools On Any Linux Distro
Katoolin | How To Install Pentesting Tools On Any Linux Distro
HackerSploit
14 Nmap Tutorial For Beginners - 2 - Advanced Scanning
Nmap Tutorial For Beginners - 2 - Advanced Scanning
HackerSploit
15 Nmap Tutorial For Beginners - 3 - Aggressive Scanning
Nmap Tutorial For Beginners - 3 - Aggressive Scanning
HackerSploit
16 Zenmap Tutorial For Beginners
Zenmap Tutorial For Beginners
HackerSploit
17 How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
HackerSploit
18 How To Setup Proxychains In Kali Linux - #2 - Change Your IP
How To Setup Proxychains In Kali Linux - #2 - Change Your IP
HackerSploit
19 How To Change Mac Address In Kali Linux | Macchanger
How To Change Mac Address In Kali Linux | Macchanger
HackerSploit
20 How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
HackerSploit
21 Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
HackerSploit
22 VPN And DNS For Beginners | Kali Linux
VPN And DNS For Beginners | Kali Linux
HackerSploit
23 Tails OS Installation And Review - Access The Deep Web/Dark Net
Tails OS Installation And Review - Access The Deep Web/Dark Net
HackerSploit
24 Steganography Tutorial - Hide Messages In Images
Steganography Tutorial - Hide Messages In Images
HackerSploit
25 The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
HackerSploit
26 Best Linux Distributions For Penetration Testing
Best Linux Distributions For Penetration Testing
HackerSploit
27 Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
HackerSploit
28 Gaining Access - Web Server Hacking - Metasploitable - #1
Gaining Access - Web Server Hacking - Metasploitable - #1
HackerSploit
29 Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
HackerSploit
30 How To Install Kali Linux On VMware  - Complete Guide 2018
How To Install Kali Linux On VMware - Complete Guide 2018
HackerSploit
31 Q&A #1 - Best Cyber-security Certifications?
Q&A #1 - Best Cyber-security Certifications?
HackerSploit
32 Terminator - Kali Linux - Multiple Terminals
Terminator - Kali Linux - Multiple Terminals
HackerSploit
33 Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
HackerSploit
34 Q&A #2 - Mr Robot?
Q&A #2 - Mr Robot?
HackerSploit
35 Metasploit Community Web GUI  - Installation And Overview
Metasploit Community Web GUI - Installation And Overview
HackerSploit
36 Linux Expl0rer - Forensics Toolbox - Installation & Configuration
Linux Expl0rer - Forensics Toolbox - Installation & Configuration
HackerSploit
37 QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
HackerSploit
38 Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
HackerSploit
39 Metasploit For Beginners - #2 - Understanding Metasploit Modules
Metasploit For Beginners - #2 - Understanding Metasploit Modules
HackerSploit
40 Kali Linux Quick Tips - #1 - Adding a non-root user
Kali Linux Quick Tips - #1 - Adding a non-root user
HackerSploit
41 Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
HackerSploit
42 Spectre Meltdown Vulnerability  - How To Check Your System
Spectre Meltdown Vulnerability - How To Check Your System
HackerSploit
43 Metasploit For Beginners - #4 - Basic Exploitation
Metasploit For Beginners - #4 - Basic Exploitation
HackerSploit
44 ARP Spoofing With arpspoof - MITM
ARP Spoofing With arpspoof - MITM
HackerSploit
45 WordPress Vulnerability Scanning With WPScan
WordPress Vulnerability Scanning With WPScan
HackerSploit
46 Generating A PHP Backdoor with weevely
Generating A PHP Backdoor with weevely
HackerSploit
47 Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
HackerSploit
48 How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
HackerSploit
49 Stacer - System Optimizer And Monitoring Tool For Linux
Stacer - System Optimizer And Monitoring Tool For Linux
HackerSploit
50 Kali Linux 2018.1 - Kernel Updates & Patches
Kali Linux 2018.1 - Kernel Updates & Patches
HackerSploit
51 MITM With Ettercap - ARP Poisoning
MITM With Ettercap - ARP Poisoning
HackerSploit
52 Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
HackerSploit
53 How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
HackerSploit
54 Channel Updates - How To Post Questions & Video Suggestions
Channel Updates - How To Post Questions & Video Suggestions
HackerSploit
55 Web App Penetration Testing - #1 - Setting Up Burp Suite
Web App Penetration Testing - #1 - Setting Up Burp Suite
HackerSploit
56 Web App Penetration Testing - #2 - Spidering & DVWA
Web App Penetration Testing - #2 - Spidering & DVWA
HackerSploit
57 Cl0neMast3r - GitHub Repository Cloning Tool
Cl0neMast3r - GitHub Repository Cloning Tool
HackerSploit
58 Kali Linux On Windows 10 Official - WSL - Installation & Configuration
Kali Linux On Windows 10 Official - WSL - Installation & Configuration
HackerSploit
59 DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
HackerSploit
60 Web App Penetration Testing - #3 - Brute Force With Burp Suite
Web App Penetration Testing - #3 - Brute Force With Burp Suite
HackerSploit

This video teaches the basics of shell scripting, including how to accept and handle user input, and how to use comments to make scripts more readable. It demonstrates the use of the `read` command and `echo` statement to handle user input and print output, and shows how to store and manipulate user input using variables.

Key Takeaways
  1. Create a new shell script using Sublime Text
  2. Use the `read` command to accept user input
  3. Store user input in a variable
  4. Use the `echo` statement to print out user input
  5. Add comments to the script to make it more readable
  6. Save and execute the script in the Terminal
💡 The `read` command is a powerful tool for accepting user input in shell scripts, and can be used in conjunction with variables and the `echo` statement to create interactive and dynamic scripts.

Related AI Lessons

AI: Energy Taker or Energy Maker
Learn how rising data center energy demands can catalyze a clean energy transition and why it matters for sustainable AI development
Medium · AI
When AI Asks for More Electricity Than a Country Can Imagine
AI's increasing power consumption is causing concerns, learn why it matters for data centers and energy supply
Medium · AI
You Are Not Behind. The World Is.
You're not behind, the world is still adapting to AI, and it's okay to take your time to learn and grow
Medium · AI
Career choice with the advent of AI - pure Computer Science or learn software with a background of core engineering area
Learn how to choose between a Computer Science and Engineering career path or combining programming with a core engineering background in the age of AI
Dev.to AI
Up next
Generative AI
Alea IT Solutions
Watch →