Shell Scripting - Menus
Key Takeaways
The video demonstrates how to create shell scripts with menus, using tools like bash and shell scripting, and techniques such as conditional statements and user input handling.
Full Transcript
[Laughter] hey guys hackersploit here back again with another video and welcome back to the show scripting series i know you guys thought that i actually left the series but uh really i haven't uh you know just really did not get the time to record all of the next videos so in this video we are going to be looking at menus and how to create menus in shell scripting and of course now the first thing that you know is coming into your mind is well why exactly do we need a menu well menus are there to provide a user with options similar to when you go to a restaurant uh you know you ask them for the menu they give you their menu and the menu then contains options available you know from which you can select and from that you get your desired meal now of course i know i've just explained it in a very layman's way but with shell scripting and really with any programming language decision making or providing the different decisions for a user to make is a very very important and that's primarily why i want to cover this because as we now look at creating even larger complex scripts remember we need to also fill them with a functionality and one of or the most important pieces of functionality is giving users options to select from and luckily for us shell scripting actually gives us a very very good base to work with when we talk about having menus and options all right so let's get started now as i mentioned menus are used to provide a user with options and given that logic we can assume that that menus also will incorporate some sort of a loop all right and obviously the value selected is going to be stored in a variable which can then be used for further conditional uh decision making or can be used with the conditional statements to make further decision and obviously to to uh to give the code continuity uh all right so uh what i'm going to do is i'm going to show you the syntax in regards to creating a menu and then we'll move on uh to creating a simple script that will essentially prompt a user uh or ask a user for a piece of information or to select an option from the menu and uh once they've um they've selected the option it's going to display to us from these from the uh it's going to display the value of the option and uh the actual value from the list uh and obviously it's going to store it's going to show us what they are and in what variables they're stored in all right so i know that sounded like a lot but uh you'll get it once we get started all right so the syntax is extremely simple all right the syntax is for creating a menu or a list and not not really a list a menu is essentially select all right so you initialize it like this all right so select simple as that but in what pretext are you going to use it and this is where we really get into it so as i mentioned it's in the form of a loop so we can say select and then we select uh and now is where we use the first variable which is going to be the variable uh that holds the option the option can be sorted into the placement so either option one option two option three all the way to as many options as you want and then we have um the uh the actual name of the option so for example if you're in a restaurant let's say option one is a burger uh option two is uh i don't know a hot dog or something like that so uh essentially there are two uh distinctions the option is the number right and uh the the actual name of the of the uh of the option is a burger so you know option one is given to the burger option two is given to the hot dog so i'll explain that so uh that would essentially come as as the following so you know you can say select option in and then we select the variable or the list that is holding these um these values for each of the options so in this case we can we can simply just say uh we can say meals as we'll follow the example over here and since we haven't initialized this list or variable it really wouldn't prompt us anything and we then say do and as as i mentioned because uh because uh sorry we uh we actually initialized that outside because it's like a loop we then insert our options or code in here all right so i just wanted to explain the simple syntax so we'll we'll follow that example we're gonna uh take a simple scenario where it's going to prompt the user to select the meal that they want to eat all right so we're just going to say echo i've already created uh selected my sh i've already created the shebang and given my script right here called menus dot shell i've given it uh executable permission so we're ready to go all right so i'm gonna say echo uh please or we can make it a bit friendly we can say welcome to uh we can say welcome to uh you know uh bobs uh welcome to bob's burgers yeah for those of you who get it uh you'll that'll be a very nice easter egg uh anyway i don't know why i'm getting into that all right so welcome to bob's burgers um we can say another echo let's just i know it's a really simple script we can say please uh select what you whoops yeah yeah we do not want to use the select right now so we will say please choose what you want to eat all right and we'll use a colon there and we'll close that all right so please select what you want to eat now we need to initialize uh we need to actually create a list or a variable that is going to hold now of course a list is much more suitable because it holds more than one value or options all right and to do this we simply it's very simple to create this a list we just give it a name so in this case i'm just going to call the list meals and the meals are going to be equal to we're just going to say um i'll just say a burger the second one we do not um we do not uh use any type of we do not split the data from from the other piece of data with a comma or a colon similar to what you do with other programming languages instead we just leave a space and we're just going to say uh we're just going to say fry's yeah we will just go give two options so burgers uh burger and fries so really really simple and that's essentially what the list is going to contain all right so we've already given we essentially already have the data that the user is going to be able to choose from so now we would say uh select all right and now we we're going to initialize the variable option because the option is a very important so option uh the option is going to be in meals as we uh as we said so the uh select the option in the meal the option can be either option one or option two all right so select the option in meals and do the following all right and in here i'm just going to say echo uh we're essentially just going to print out what the user so it says uh what what what's going to happen is the user is going to enter what meal they want and then after where they've entered it the script is going to display what option they selected and what meal they want and then you know it can simply say uh you know do you want to confirm this order or something like that all right so echo we're going to say the selected option is we're just going to display just to make sure it all works now the selected option or the option is given uh or stored in the variable reply i don't know whether i've mentioned this before but that can be also donated [Music] denoted by the reply variable all right so we're just going to initialize that variable right over there and it is already initialized as you can see it's not going to be initialized anyway in the script but once there is a reply given in into a menu or after you've selected an option it is stored in the reply variable all right and now we're just going to say echo so we said the selected option is reply and that's going to display the option all right uh so now we can say the selected season is the we can say the selected uh meal sorry uh what am i saying so the select uh oops the selected meal is and i'll explain this is if it's a bit confusing the selected meal is uh now we select the actual uh option that we specified right over here all right so we're just gonna say option and we close that and we are done all right so before i actually explain what's going on here let me just run this script so let me save that and let me exit and i'm just going to launch the script all right so menus.shell and already you can see uh it's going to prompt us and it's going to say welcome to bob's burgers please choose what you want to eat all right and it's going to give us two options very very nice burger and fries so i'm going to say let's say i want to choose a burger so i'm going to select option 1 and i'm going to hit enter and it's going to prompt out the selected option is 1 correct and the selected meal is burger now after this one could say do you want to confirm this order and this is the simple logic behind programs or scripts that we see in you know in in the real world for example when you're ordering something at mcdonald's they have that that new system where you can you know you order it yourself this is the simple logic this is not how it works but this is the logic here so you know you provide a user with options to select from and then those options once selected can then be used in different conditional statements so let's say i selected burger and now from the from the reply variable i can say if the reply variable is a one then i want you to prompt uh you i want you to ask the user whether they want a chicken burger or a beef burger right so you get the idea all right so i'm just going to close i'm just going to exit that script and what i'm going to do is i'm just going to open nano so let me explain what we've done here all right so we've asked the user you know prompted the user with a nice welcome message so welcome to bob's burgers please choose the please choose what you want to eat and the meals are the list that contains the meals is right over here and you can give it as many values as you want all right it really doesn't matter uh and then we've said all right i want you to create a menu as we're going to select an option we initialize the option variable yeah and again you can name that whatever you want you can call that option you can call it choice whatever makes sense logically all right so select option in the list meals all right so now each of these values is going to be denoted an option so burger is option one fries is option two if i would have added hot dog or you know something like uh fried chicken three and four respectively so in that list i want you to do the following i want you to uh to print out the following so you want you to print out the selected option is and you want you to display the variable that stores the value of the option the the value of the option that the user entered uh or the uh the value of the option denoted from the list meals so that can be the option one so if it's option one it'll simply print out what option the user entered all right and the second one is going to print out the selected meal is and from the option here that we created it's simply going to print out what the actual option is from the list not the uh the the option number but the actual value of the option all right and that is simply what our script is going to do now most of you might be curious and you might be thinking well how can we utilize this uh to make a really really awesome script similar to the ones you see many of the scripts we see out there many of the popular network scanning scripts and enumeration scripts all have options or menus within them and that is to provide the user with a more tailor-made functionality or in regards to what they want to use uh the script for but this is very very important as we are going to be utilizing this because i am creating my own network scanning and enumeration script for linux hosts and we're going to be creating it in this series and we need to get all the important things that you need to understand out of the way alright so that's going to be it for this video guys uh if you enjoyed this video or found value in it please leave a like down below if you have any questions or suggestions let me know in the comment 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
Github Repo: https://github.com/AlexisAhmed/Shell-Scripts
⭐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
⚡
⚡
⚡
⚡
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
The AI Hype Cycle: Calm Before the Next Breakthrough?
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI