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