first commit

This commit is contained in:
Tyleo Dv. Delaware 2024-02-18 22:29:57 +01:00
commit 99f395b01b
64 changed files with 2319 additions and 0 deletions

View file

@ -0,0 +1,10 @@
# Script for adding, commiting and pushing on gitlab or github.
echo "Adding all"
sleep 1
git add * || echo "Adding failed, check your files !"
echo "Commit everything, enter your message !"
sleep 1
git commit || echo "Commiting failed, check your connection and your git clone"
echo "Pushing ! Enter your ID and Pass !"
git push || echo "Incorrect password, login or bad internet connection (upper 100ms ping)"
echo "Is done ! your master has been updated, active folder is `pwd`"

11
README.md Executable file
View file

@ -0,0 +1,11 @@
En ce glorieux jour du mardi 29 janvier 2019, moi The Velociraptor place ce projet de scripts libres sous la licence « Fais pas chier ».*
La copie, la reproduction ou la modification est autorisé en indiquant et conservant le nom de l'auteur. Ce projet est Open Source.
Copy, Fork or Modifications are allowed by indicating and keeping author name. This project is Open Source.
The Velociraptor 0.14 (C) 2019.1
All my script are runnable using ./ or system $PATH variable. My scripts DOES NOT contain any virus, malware or spyware methods. If you want to ensure you're safe, use cat [file] commande to see my code script.
Tout mes scripts sont fonctionnels avec le ./ ou la variable systéme $PATH. Mes scripts NE CONTIENNENT aucun virus, malware ou logiciels espions aux méthodes douteuses. Si vous désirez vous assurez qu'aucun virus n'est présent, utiliser la commande cat [fichier] pour voir mes codes.

491
RESSOURCES/decorations.md Normal file
View file

@ -0,0 +1,491 @@
██████████████████████████
█ Tableau des caractéres █
█Spéciaux pour décoration█
█ de Script, textes etc..█
██████████████████████████
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒Concept Velociraptor 014▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
██████████████████████████
║ ╔ ╝ ╚ ╗ □ ╣ ⩇ 🥐 🥖 🍟
██████████████████████████
⟸ ⟹ ⟺ ⟼
██████████████████████████
⟩⟫⟪⟨⤑⤧
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████
██████████████████████████

BIN
SH/.stdgame.sh.swp Normal file

Binary file not shown.

39
SH/additionvar.sh Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
number=1
echo "
███████████████████████████████
█This script will add your █
█custom value to the variable █
\$number, enter your value █
█ █
█it will echo result to you ! █
█ █
█Starting value : 1 (number=1)
███████████████████████████████
"
echo $number
while true
do
echo -n "Your value : "
read add
if [[ "$add" =~ [0-9] ]]; then
let "number += add"
echo $number
if [[ $number -ge 1000 ]]; then
echo "Limit reached!"
echo Aborted
exit
fi
elif [[ $add = [Ee]xit ]]; then
exit
elif [[ $add = EXIT ]]; then
exit
elif [[ $add = [Qq]uit ]]; then
exit
elif [[ $add = QUIT ]]; then
exit
else
echo "Numbers only"
exit
fi
done

9
SH/checkuserexistence.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
echo -n "Enter a username to check: "
read name
if grep $name /etc/passwd > /dev/null
then
echo "$name is on this system"
else
echo "$name does not exist"
fi

13
SH/checkuserexistenceloop.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
name=$USER
while [[ $name = * ]]; do
echo -n "Enter a username to check: "
read name
if grep $name /etc/passwd > /dev/null
then
echo "$name is on this system"
else
echo "$name does not exist"
fi
done

17
SH/chooseyourcalendar.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# This condition allow you to choose between cal or calendar commands.
ACTIVECOMMAND=
clear
echo "Choose your calendar !"
echo " Simple / Complex "
read ACTIVECOMMAND
# ---------------------------
if [ $ACTIVECOMMAND = Simple ]; then
cal
elif [ $ACTIVECOMMAND = Complex ]; then
calendar
elif [ $ACTIVECOMMAND = Simplex ]; then
echo "En fait, t'est complétement con."
else
echo "Eheh, no correspondance."
fi

16
SH/dialog01.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
printf '
Dialogue entre deux personne
'
echo "Type 'start'"
read start
if [[ $start = start ]]; then
read dialog
echo "Bonjour"
read dialog
echo "Oui et toi?"
exit
else
echo
exit
fi

27
SH/echodisturb.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
# Using pipes and redirection to make the echo disturbing
echo "Je m'appelle Henry"
echo "Je m'appelle Henry" | tr 'Henry' 'Hanry'
echo "Je m'appelle Henry" | tr 'appelle' 'alleppe'
echo "Je m'appelle Henry" | tr 'Je' 'Tu'
echo "Je m'appelle Henry" | tr 'm' 'p'
echo "Je m'appelle Henry" | tr 'appe' 'mapp'
echo "Je m'appelle Henry" | tr "Je m'appelle Henry" "yrneH elleppa'm eJ"
# Pipes can be used to replace characters (or Char).
echo "1" | tr '1' '2' # this will show 2 and not 1.
echo "no" | tr 'no' 'yes' # this will show yes and not no.
# Pipes can interfer with result of commands, for example :
echo "Normal LS"
ls -l
echo "Anormal LS"
ls -l | tr 'drwxrwxrjanvdecnovjunavrmayaug' '00'
echo "The command is : ls -l | tr 'drwxrwxrjanvdecnovjunavrmayaug' '00'"
echo "Or..."
ls -l | echo "Ahah !"
echo 'The Command is : ls -l | echo "Ahah !"'
echo "This make the command LS in bad condition due to pipe."
echo "The Tr command is usefull for maintenancy taskes or for changing a sensible value."

90
SH/echogame.sh Executable file
View file

@ -0,0 +1,90 @@
#!/bin/sh
# The game of CD, MV and CP !
# Experimental. This script will created and use only one additional folder.
# --------------------------------------------------------------------------
mkdir ./ScriptGameCDMVCP
cd ./ScriptGameCDMVCP
sleep 2
mkdir folder1 folder2 folder3
sleep 2
touch file1 file2 file3
# Creation finished.
# Now, moving file1 to folder1
mv file1 folder1/
# Now, moving file2 to folder2
mv file2 folder2/
# Now, moving file3 to folder3
mv file3 folder3/
echo "Waiting 10 seconds, and showing the part of script that has moved theses files!"
printf '
# Now, moving file1 to folder1
mv file1 folder1/
# Now, moving file2 to folder2
mv file2 folder2/
# Now, moving file3 to folder3
mv file3 folder3/ \n
'
echo "CTRL+C to abort"
echo "Waiting..."
sleep 10 # Waiting 10 seconds to let you see the script.
# Now, renaming all "file*" by "data*" with mv command
mv ./folder1/file1 ./folder1/data1
mv ./folder2/file2 ./folder2/data2
mv ./folder3/file3 ./folder3/data3
echo "Done !"
ls -lR folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity
sleep 10 # Always let the time to see the LS. Is very important to make the time easier.
echo "Showing the script !"
printf '
# Now, renaming all "file*" by "data*" with mv command
mv ./folder1/file1 ./folder1/data1
mv ./folder2/file2 ./folder2/data2
mv ./folder3/file3 ./folder3/data3
echo "Done !"
ls -R folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity \n
'
# Now, copying all files. The objective is to get all data* into all folder*
cp ./folder1/data1 ./folder2
cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries
# -------------------------------------------------
cp ./folder3/data3 ./folder2
cp ./folder2/data2 ./folder3 # Doing the same thing
# -------------------------------------------------
cp ./folder1/data1 ./folder3
cp ./folder3/data3 ./folder1 # Doing the same thing another time
# -------------------------------------------------
# Showing the script :
echo "Now, you can see the script !"
printf '
# Now, copying all files. The objective is to get all data* into all folder*
cp ./folder1/data1 ./folder2
cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries
# -------------------------------------------------
cp ./folder3/data3 ./folder2
cp ./folder2/data2 ./folder3 # Doing the same thing
# -------------------------------------------------
cp ./folder1/data1 ./folder3
cp ./folder3/data3 ./folder1 # Doing the same thing another time
# ------------------------------------------------- \n
'
# after that, we have copied everything. Now, we will show the work.
ls -R folder1 folder2 folder3
sleep 10
echo "This script is a very simple script."
printf '
For learning, for exploring and for editing them as you want !
'
# after, the script will clean up by deleting the folder completely and recursively.
# Try to loop !
rm -rf ../ScriptGameCDMVCP # Removing everything in folder1, folder2 and folder3
echo "The LS :"
echo "`ls -laR ./`\n Listing done!"
echo "The file has been removed successfully!"
echo "script end."

95
SH/echogamenorm.sh Executable file
View file

@ -0,0 +1,95 @@
#!/bin/sh
# The game of CD, MV and CP ! (no rm version)
# Experimental. This script will created and use only one additional folder.
# CLEANING
rm -rf ./ScriptGameCDMVCP 2> /dev/null
# --------------------------------------------------------------------------
mkdir ./ScriptGameCDMVCP
cd ./ScriptGameCDMVCP
sleep 2
mkdir folder1 folder2 folder3
sleep 2
touch file1 file2 file3
# Creation finished.
# Now, moving file1 to folder1
mv file1 folder1/
# Now, moving file2 to folder2
mv file2 folder2/
# Now, moving file3 to folder3
mv file3 folder3/
echo "Waiting 10 seconds, and showing the part of script that has moved theses files!"
printf '
# Now, moving file1 to folder1
mv file1 folder1/
# Now, moving file2 to folder2
mv file2 folder2/
# Now, moving file3 to folder3
mv file3 folder3/ \n
'
echo "CTRL+C to abort"
echo "Waiting..."
sleep 10 # Waiting 10 seconds to let you see the script.
# Now, renaming all "file*" by "data*" with mv command
mv ./folder1/file1 ./folder1/data1
mv ./folder2/file2 ./folder2/data2
mv ./folder3/file3 ./folder3/data3
echo "Done !"
ls -lR folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity
sleep 10 # Always let the time to see the LS. Is very important to make the time easier.
echo "Showing the script !"
printf '
# Now, renaming all "file*" by "data*" with mv command
mv ./folder1/file1 ./folder1/data1
mv ./folder2/file2 ./folder2/data2
mv ./folder3/file3 ./folder3/data3
echo "Done !"
ls -R folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity \n
'
# Now, copying all files. The objective is to get all data* into all folder*
cp ./folder1/data1 ./folder2
cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries
# -------------------------------------------------
cp ./folder3/data3 ./folder2
cp ./folder2/data2 ./folder3 # Doing the same thing
# -------------------------------------------------
cp ./folder1/data1 ./folder3
cp ./folder3/data3 ./folder1 # Doing the same thing another time
# -------------------------------------------------
# Showing the script :
echo "Now, you can see the script !"
printf '
# Now, copying all files. The objective is to get all data* into all folder*
cp ./folder1/data1 ./folder2
cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries
# -------------------------------------------------
cp ./folder3/data3 ./folder2
cp ./folder2/data2 ./folder3 # Doing the same thing
# -------------------------------------------------
cp ./folder1/data1 ./folder3
cp ./folder3/data3 ./folder1 # Doing the same thing another time
# ------------------------------------------------- \n
'
# after that, we have copied everything. Now, we will show the work.
ls -R folder1 folder2 folder3
sleep 10
echo "This script is a very simple script."
printf '
For learning, for exploring and for editing them as you want !
'
# after, the script will clean up by deleting the folder completely and recursively.
# Try to loop !
echo "This version let the folder intact. You can explore it."
echo "This script delete any old folder named exactly same. Be aware!"
echo "The LS :"
echo "`ls -laR ./`\n Listing done!"
echo "The file has been removed successfully!"
echo "script end."

27
SH/echoloop1.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
# --------------------------------
while true
do
clear
echo "1"
sleep 1
clear
echo "2"
sleep 1
clear
echo "3"
sleep 1
clear
echo "4"
sleep 1
clear
echo "5"
sleep 1
clear
echo "Bah alors, faut m'arréter !"
sleep 1
clear
echo "CTRL+C !"
sleep 3
clear
done

9
SH/echols.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
while true
do
ls
echo " "
echo "Updating..."
sleep 1
clear
done

17
SH/echoperma.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
clear
echo "After this title, press CTRL+C to stop the script."
echo "This script is innofensive and has been created for"
echo "learning. See it by typing < cat [file] >"
echo " "
echo "Waiting 5 seconds"
sleep 5
# Start of script !
while true
do
echo "Perma Echo"
clear
done
# In this script, you can see an infinite loop without any sleep commands, That produce permanently
# same command and the command is in loop state. That can be usefull for doing anything infinitly.

31
SH/fakeloadingscreen1.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
printf '
-------------------
FAKE LOADING SCREEN
-------------------\n
'
echo "Type 'start' to start loading !"
echo "CTRL+C to stop loading !"
read loading
while true
do
if [[ $loading = start ]]; then
clear
echo "---------"
echo "Loading ."
echo "---------"
sleep 1
clear
echo "----------"
echo "Loading .."
echo "----------"
sleep 1
clear
echo "-----------"
echo "Loading ..."
echo "-----------"
sleep 1
else
exit
fi
done

53
SH/fakeloadingscreen2.sh Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
while true
do
clear
echo "-"
sleep 1
clear
echo "--"
sleep 2
clear
echo "---"
sleep 3
clear
echo "----"
sleep 4
clear
echo "-----"
sleep 5
clear
echo "------"
sleep 6
clear
echo "-------"
sleep 7
clear
echo "--------"
sleep 8
clear
echo "---------"
sleep 9
clear
echo "----------"
sleep 10
clear
echo "-----------"
sleep 11
clear
echo "------------"
sleep 12
clear
echo "-------------"
sleep 13
clear
echo "--------------"
sleep 14
clear
echo "---------------"
sleep 15
clear
echo "----------------"
sleep 1
clear
done

53
SH/fakeloadingscreen3.sh Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
while true
do
clear
echo "-"
sleep 1
clear
echo "--"
sleep 1
clear
echo "---"
sleep 1
clear
echo "----"
sleep 1
clear
echo "-----"
sleep 1
clear
echo "------"
sleep 1
clear
echo "-------"
sleep 1
clear
echo "--------"
sleep 1
clear
echo "---------"
sleep 1
clear
echo "----------"
sleep 1
clear
echo "-----------"
sleep 1
clear
echo "------------"
sleep 1
clear
echo "-------------"
sleep 1
clear
echo "--------------"
sleep 1
clear
echo "---------------"
sleep 1
clear
echo "----------------"
sleep 1
clear
done

12
SH/greaterthancent.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
echo "Choose a number greater than 100"
read lecture
number=${lecture:-0}
while [ $number -le 100 ]
do
echo "$number is not greater than 100."
echo "Please enter a number greated than 100!"
read lecture
number=${lecture:-0}
done
echo "Finally, $number is greater than 100 !"

8
SH/hourinlive.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
while true
do
date +%H:%M:%S
echo "CTRL+C to stop"
sleep 1
clear
done

37
SH/lstotextfile.sh Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
echo "
------------------------
Add ls results to a file
------------------------
You can choose extension and filename
separately.
The file will be stored into a folder
named "LSFILEFOLDER"
"
echo "Choose your filename without extension : "
echo
echo -n "filename="
read fname
echo
echo "Choose your extension : "
echo -n "extension=."
read extf
if [ -f "./LSFILEFOLDER/$fname.$extf" ]
then
echo "File exist"
echo Aborting!
exit
elif [ test ]
then
mkdir ./LSFILEFOLDER &>> /dev/null
touch ./LSFILEFOLDER/$fname.$extf &>> /dev/null
ls ./LSFILEFOLDER/$fname.$extf &>> /dev/null
echo
echo "Now, choose a location of ls command to make a result!"
echo
echo -n "/"
read tree
ls /$tree &>> ./LSFILEFOLDER/$fname.$extf
fi

28
SH/multicondition.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
echo "This script is designed for demonstrating variable into conditions"
echo "------------------------------------------------------------------"
echo "You can enter any other words than asked for seeing the behavior !"
echo
echo "In this script, you will set the variable by READ command :"
echo
echo -n "Enter 'hello' : "
read hello
echo "The variable \$hello is now set to $hello"
if [[ $hello = hello ]]; then
echo "The value is $hello and correspond to the asked one"
else
echo "The value is $hello and do not correspond to the asked one"
fi
echo
echo -n "Another example, enter anything you want excepting 'world' :"
read world
echo
echo "Now, the \$world variable is set to $world"
echo
if [[ $world = world ]]; then
echo "You have entered '$world' and is the excepting one !"
elif [[ $world = * ]]; then
echo "You have entered '$world' and it's OK"
fi
echo
echo "Script Ended."

25
SH/oneplusoneequaltwo.sh Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
echo "Hey, this is a little calcul with 2 try :"
echo -n "1+1="
read result
if [[ $result = 2 ]]; then
echo "Good ! It is right !"
elif [[ $result = * ]]; then
echo "Wrong answer !"
echo "Retry !"
echo -n "1+1="
read result
if [[ $result = 2 ]]; then
echo "Yes ! It is right !"
elif [[ $result = * ]]; then
echo "Ooh nooo... Is wrong !"
echo "Retry !"
echo -n "1+1="
read result
if [[ $result = 2 ]]; then
echo "Yes ! IS RIGHT !!!!"
elif [[ $result = * ]]; then
echo "Ahahahahha nooo !!! Loooser !"
fi
fi
fi

5
SH/shwithdoublecrochet.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
ECH=0
if [[ ECH=0 ]]; then
echo "$ECH"
fi

6
SH/simpleconditionvar.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
variable=testvariable
if [ $variable = testvariable ]
then
echo "Variable $variable"
fi

22
SH/theconditionofdeath.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/sh
echo "Ce script étudie l'usage des conditions IF-FI"
echo "---------------------------------------------"
echo "Alors, nous allons prendre un exemple :"
# -------------------------------------------------
echo "Choisissez entre 'on', 'off' et 'middle'"
read DEATH
echo "You have choosen $DEATH"
echo PLEASE
sleep 1
echo WAIT
sleep 3
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ $DEATH = off ]; then
echo "Il est mort"
elif [ $DEATH = on ]; then
echo "Il est vivant"
elif [ $DEATH = middle ]; then
echo "Il est quelque chose mais je ne sais pas quoi !"
else
echo "Réponse incorrectesh"
fi

12
SH/theparrot.sh Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
while true
echo -n "Choose a number, I will repeat it after you : "
read magicnumber
do
if [[ $magicnumber = * ]]; then
echo "$magicnumber"
echo -n "Choose another one"
read magicnumber
echo "$magicnumber"
fi
done

11
SH/userisroot.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
if [ $USER = root ]; then # Check for USER=root
echo "You are root"
else
echo "You are not root !"
fi
# ------------------------------------------------------------------------ #
# This script say "You are not root" when the variable $USER is not "root" #
# If the script see "root" in $USER variable, it will say "You are root"-- #
# In the case of nothing is into the variable, it will say a joke.-------- #
# ------------------------------------------------------------------------ #

19
SH/variablegame.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
# Registering variables
VARIABLE0001=1
VARIABLE0002=2
VARIABLE0003=3
VARIABLE0004=4
VARIABLE0005=5
OUTOFRANGE=`echo "Out Of Range !"`
# ---------------------
# We will use variables for creating computing :
echo "$VARIABLE0001 + $VARIABLE0001 = $VARIABLE0002"
echo "$VARIABLE0002 + $VARIABLE0002 = $VARIABLE0004"
echo "$VARIABLE0004 + $VARIABLE0004 = $OUTOFRANGE"
echo "$VARIABLE0005 = $VARIABLE0005 after that, is $OUTOFRANGE"
# End

9
SH/variablesonscene.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
# Examples of variables
FILENAME=1
ANIMAL=2
COCHONS=3
CECIESTUNEVARIABLE=4
echo "$FILENAME + $ANIMAL = $COCHONS"
echo "Si on ajoute $FILENAME à $COCHONS on obtient alors"
echo "$CECIESTUNEVARIABLE"

17
SH/viveles.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
echo "Hey, tu sais quoi?"
echo "Dit moi un mot et je dirait que j'en suis ravi"
echo
echo -n "Votre mot : "
read word
echo
echo "D'accord..."
echo "Hmmm... (L'homme réfléchissait alors)"
sleep 5
echo "Je suis tout a fait ravis de ce $word"
# Ainsi, ce script montre une simple varable $word
# nous l'utilisons ici en tant que valeur d'entrée
# c'est elle qui sera défini par l'utilisateur
# à la commande "read [variable]". Imaginez faire
# cela dans des conditions, des cases ou même un
# simple bash script ! C'est magique !

27
SH/writethetext.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# The objective is to let the user writing their own text.
# Five lines, defined by five variables :
one=
two=
three=
four=
five=
# At start, variables are empty.
# Now, asking for each lines :
echo "Enter the first line"
read one
echo "Enter the second one"
read two
echo "Enter the third one"
read three
echo "Enter the four one"
read four
echo "Enter the five one"
read five
echo
echo "Ok, you have entered :"
echo $one
echo $two
echo $three
echo $four
echo $five

34
SH/writethetextonfile.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# The objective is to let the user writing their own text.
# Five lines, defined by five variables :
one=
two=
three=
four=
five=
file=filename.txt
# At start, variables are empty.
# Now, asking for each lines :
echo "Enter the first line"
read one
echo "Enter the second one"
read two
echo "Enter the third one"
read three
echo "Enter the four one"
read four
echo "Enter the five one"
read five
echo
echo -n "Choose your filename : "
read file
echo
echo "Ok, your text will be written on $file"
echo $one >> ./$file
echo $two >> ./$file
echo $three >> ./$file
echo $four >> ./$file
echo $five >> ./$file
echo "Done ! on file ($file)"
echo "----------------------"
cat ./$file

View file

@ -0,0 +1,2 @@
Attention, les script présent dans SH_EXPERIMENTAL/LOOP
***sont des scripts loop boucle infinies. Faire CTRL+C pour stopper !***

View file

@ -0,0 +1,4 @@
#!/bin§bash
echo "Script 1 en cours d'execution"
sleep 1
sh script2

View file

@ -0,0 +1,4 @@
#!/bin/bash
echo "Script 2 en cours d'execution"
sleep 1
sh script3

View file

@ -0,0 +1,4 @@
#!/bin/bash
echo "Script 3 en cours d'execution"
sleep 1
sh script1

View file

@ -0,0 +1,6 @@
All projects in this folder are EXPERIMENTAL but very interesting.
Theses scripts explore different maner to create interactive scripts.
Theses script will NEVER include comments (# ....)

View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
question='Please enter your choice'
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1")
echo "Chosen 1 !"
;;
"Option 2")
echo "Chosen 2 !"
;;
"Option 3")
echo "Chosen 3 !"
;;
"Quit")
break
;;
*) echo "Invalid"
esac
done

View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
ip1=0
ip2=0
ip3=0
ip4=0
cb1=
cb2=
cb3=
cb4=
printf '
------------------------------
IP BIN TO IP DEC CONVERTER
------------------------------
This script will convert your binary
ip address to decimal one.
Enter all dot to dot values
(xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx)
'
echo "Enter your first dot (________.) : "
read ip1
echo "ibase=2;obase=A;$ip1" | bc > ....cb1
echo "Enter your second dot ($ip1.________): ."
read ip2
echo "ibase=2;obase=A;$ip2" | bc > ....cb2
echo "Enter your third dot ($ip1.$ip2.________): ."
read ip3
echo "ibase=2;obase=A;$ip3" | bc > ....cb3
echo "Enter your fourth ($ip1.$ip2.$ip3.________): ."
read ip4
echo "ibase=2;obase=A;$ip4" | bc > ....cb4
echo "Your binary ip address :"
echo "$ip1.$ip2.$ip3.$ip4"
echo "Translated in Decimal :"
echo "`cat ....cb1`.`cat ....cb2`.`cat ....cb3`.`cat ....cb4`"
echo
echo "Finished."
rm ....cb1 ....cb2 ....cb3 ....cb4

18
SH_PROJECTS/binarytodecimal.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# This script translate decimal read values to binary one.
number=0
printf '
-------------------------------
BINARY TO DECIMAL CONVERTER
-------------------------------
This script will translate your
binary number to decimal one.
Using bc command
(need to be present on your system to work)
'
echo -n "Enter your value : "
read number
echo "Converting!"
sleep 1
echo "ibase=2;obase=A;$number" | bc

29
SH_PROJECTS/calendarmenu.sh Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# This script show a menu to choose type of calendar between Simple, Complex and Date.
printf '
----------------------------------
DATE AND CALENDAR CHOOSER MENU
----------------------------------
Choose between :
current : calendar of current month
three : calendar of three month and current one at middle
date : Show the date of today
hour : Show the clock (HH:MM:SS)
'
echo -n "Your choice : "
read cli
echo
if [[ $cli = [Cc]urrent ]]
then
cal
elif [[ $cli = [Tt]hree ]]
then
cal -3
elif [[ $cli = [Dd]ate ]]
then
echo "La date d'aujourd'hui : `date +"%A %d %B %Y"`"
elif [[ $cli = [Hh]our ]]
then
echo "L'heure actuelle : `date +%H:%M:%S`"
fi

View file

@ -0,0 +1,9 @@
if [[ conditions ]]; then
actions
elif [[ conditions ]]; then
actions
elif [[ conditions ]]; then
actions
fi
# You can use multiple times ELIF conditions

View file

@ -0,0 +1,3 @@
else [[ conditions ]]; then
actions
fi # the fi is if inverted (inversé)

View file

@ -0,0 +1,3 @@
if [[ conditions ]]; then
actions
fi

View file

@ -0,0 +1,81 @@
#!/usr/bin/env bash
# Start and between
IF=
ELIF=
ELSE=
# Ending
THEN=
FI=
# Starting script
printf '
-------------------------------
IF, ELIF, ELSE, THEN et FI.
-------------------------------
Ce jeu est en Français et sera
toujours traduit en anglais
This game is in French and will
always be translated to English
-------------------------------
le but est simple
the objective is easy
vous diposez des mots suivants :
you own theses words :
if, fi, then, else, et elif.
Aprés avoir lu le systéme de condition
After reading condition system :
A chaque fois que un mot apparait
sur le terminal, saisir le mot suivant.
For each time of word appear in the
terminal, type the next word.
'
echo
echo -n "Go? [Y/n]"
read go
if [[ $go = [Yy] ]]; then
echo "Starting !"
echo
echo -n "if [[ test ]]; "
read IF
if [[ $IF = then ]]; then
echo "Good !"
echo "This is an example of code :"
cat ./cgamesx785qs_data/.ifscript
elif [[ $IF = * ]]; then
echo "No, the right answer is 'then'"
echo "This is an example of code :"
cat ./cgamesx785qs_data/.ifscript
fi
echo
echo -n "else "
read ELSE
if [[ $ELSE = fi ]]; then
echo "Good !"
echo "This is an example of code :"
cat ./cgamesx785qs_data/.elsescript
elif [[ $ELSE = * ]]; then
echo "Bad answer, the right answer is 'fi'"
echo "This is an example of code :"
cat ./cgamesx785qs_data/.elsescript
fi
echo "the last one :"
echo "if, tip : Excepting 'then', When I want to do other thing in certain cases"
read ELIF
if [[ $ELIF = elif ]]; then
echo "Good answer !"
echo "This is an example of code :"
cat ./cgamesx785qs_data/.elifscript
elif [[ $ELIF = * ]]; then
echo "Bad answer, the right is : elif, used to make another condition after the first one."
echo "This is an example of code :"
cat ./cgamesx785qs_data/.elifscript
fi
elif [[ $go = [Nn] ]];[[ $go = " " ]]; then
echo "Game aborted !"
exit
fi

View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
ip1=0
ip2=0
ip3=0
ip4=0
bc1=
bc2=
bc3=
bc4=
printf '
------------------------------
IP DEC TO IP BIN CONVERTER
------------------------------
This script will convert your ip address
to binary one.
Enter all dot to dot values (xxx.xxx.xxx.xxx)
'
echo "Enter your first dot ___. : "
read ip1
echo "scale=8;obase=2;$ip1" | bc > ....bc1
echo "Enter your second dot $ip1.___.: ."
read ip2
echo "scale=8;obase=2;$ip2" | bc > ....bc2
echo "Enter your third dot $ip1.$ip2.___.: ."
read ip3
echo "scale=8;obase=2;$ip3" | bc > ....bc3
echo "Enter your fourth $ip1.$ip2.$ip3.___: ."
read ip4
echo "scale=8;obase=2;$ip4" | bc > ....bc4
echo "Your ip address :"
echo "$ip1.$ip2.$ip3.$ip4"
echo "Translated in Binary :"
echo "`cat ....bc1`.`cat ....bc2`.`cat ....bc3`.`cat ....bc4`"
echo
echo "Finished."
rm ....bc1 ....bc2 ....bc3 ....bc4

18
SH_PROJECTS/decimaltobinary.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# This script translate decimal read values to binary one.
number=0
printf '
-------------------------------
DECIMAL TO BINARY CONVERTER
-------------------------------
This script will translate your
decimal number to binary one.
Using bc command
(need to be present on your system to work)
'
echo -n "Enter your value : "
read number
echo "Converting!"
sleep 1
echo "obase=2;$number" | bc

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# This script will ask you to install ZSH (Ubuntu/DEB/APT Only)
# Package : zsh, using variable.
# To make this script working fully, you need to run it as root.
# Read the script before if you are aware !
pti=zsh
echo -n "Do you want to install Z-Shell ($pti)?(Y/n)"
read ask
if [[ $ask = [Yy] ]]; then
echo "Installing Z-Shell or ($pti)..."
apt install $pti &> /dev/null
echo "Finished, checking if the package is present..."
checkpkg=`which zsh`
if [[ $checkpkg = /usr/bin/zsh ]]; then
echo "Package present."
echo "Installation success"
elif [[ $checkpkg = * ]]; then
echo "Error !"
echo "Try to install manually"
fi
elif [[ $ask = [Nn] ]]; then
echo "Aborted."
exit
elif [[ $ask = * ]]; then
echo "Aborted."
exit
fi

View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
ip4="inet "
ip6="inet6 "
eth="ether "
loop="loop "
printf '
/----------------------------------\
| INTERNET PROTOCOL MENU CHOOSER |
\----------------------------------/
You can show IP Configuration
with this tool. Select your choice :
0) Show INETv6 config
1) Show INETv4 config
2) Show ETH config
3) Show LOOP config
'
echo -n "Make your choice : "
read ask
if [[ $ask = 0 ]]; then
ip addr show primary | grep "inet6 "
elif [[ $ask = 1 ]]; then
ip addr show primary | grep "inet "
elif [[ $ask = 2 ]]; then
ip addr show primary | grep "ether "
elif [[ $ask = 3 ]]; then
ip addr show primary | grep "loopback"
elif [[ $ask = "" ]];then
echo "No input detected."
echo "Aborting!"
exit
elif [[ $ask = * ]]; then
echo "Incorrect value detected."
echo "Aborting!"
exit
fi

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# This script will ask you for showing LS. but in different way, with -l, -la, and -x.
# -la will be shown "hidden " storage into lsh variable
# -l will be shown "complex" storage into lsc variable
# -x will be shown "simple " storage into lss variable
# Used variable : $lschoose, $lsh/c/s/n
lsh="ls -la"
lsc="ls -l"
lss="ls -x"
lsn="ls"
lschoose=
echo -n "Choose your LS, it will show the current directory (hidden,complex,simple): "
read lschoose
if [[ $lschoose = hidden ]]; then
$lsh ./
elif [[ $lschoose = complex ]]; then
$lsc ./
elif [[ $lschoose = simple ]]; then
$lss ./
elif [[ $lschoose = * ]]; then
$lsn ./
fi

46
SH_PROJECTS/pingtester.sh Executable file
View file

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Using variables, manipulating Ping command.
local=127.0.0.1
internetdns=8.8.8.8
standardpriv=192.168.1.1
altstd1=172.16.1.1
altstd2=10.0.0.1
altstd3=10.0.1.1
custom=0.0.0.0
ping=
printf '
------------------------------
PINGv4 TESTING MENU V1.0
------------------------------
Choose an ip address to test :
local : Ping 127.0.0.1 loopback ip
internetdns : Ping Google DNS (8.8.8.8) for testing Internet Connection
standardpriv : Ping Home IP Modem (192.168.1.1) for testing home connection or company with this IP
altstd1 : Ping Alternative private IP (172.16.1.1)
altstd2 : Ping Alternative private IP (10.0.0.1)
altstd3 : Ping Alternative private IP (10.0.1.1)\n
manual : Ping Custom IP (XX.XX.XX.XX)
'
echo "Make your choice : "
read ping
if [[ $ping = local ]]; then
ping $local
elif [[ $ping = internetdns ]]; then
ping $internetdns
elif [[ $ping = standardpriv ]]; then
ping $standardpriv
elif [[ $ping = altstd1 ]]; then
ping $altstd1
elif [[ $ping = altstd2 ]]; then
ping $altstd2
elif [[ $ping = altstd3 ]]; then
ping $altstd3
elif [[ $ping = manual ]]; then
echo -n "Enter IP : "
read custom
ping $custom 2> /dev/null
else
echo "Aborting!"
exit
fi

68
SH_PROJECTS/showblkmenu.sh Executable file
View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# This script will show a menu that allow user to show lsblk
# and ls /dev/ commands with filters. Using variables.
lsblk="lsblk"
lsblksd="ls /dev/sd*"
lsblktty="ls /dev/tty*"
lsblknvme="ls /dev/nvme*"
lsblkloop="ls /dev/loop*"
lsblkmem="ls /dev/mem*"
lsblkall="ls /dev/"
grepnvme=
grepsd=
blk=
clear
printf '
---------------------
BLK MENU CHOOSER v1.0
---------------------
This script menu show your current partitions,
virtual devices etc.. Into /dev/
and lsblk command.
Choose blk :
1) list all partitions and disks
2) list all sd* devices in /dev/ (if exist)
3) list all tty* lines in /dev/
4) list all nvme* devices in /dev/ (if exist)
5) list all loop virtual devices
6) list all mem devices in /dev/
7) list everything in /dev/
\n
'
echo -n "Make your choice (1/2/3/4/5/6/7/Abort) : "
read blk
if [[ $blk = 1 ]]; then
echo "Listing blk partitions..."
$lsblk 2> /dev/null
elif [[ $blk = 2 ]]; then
echo "Listing Special Devices into /dev !"
$lsblksd 2> /dev/null
elif [[ $blk = 3 ]]; then
echo "Listing TTY lines (in /dev/)"
$lsblktty 2> /dev/null
elif [[ $blk = 4 ]]; then
echo "Listing NVME devices in /dev/"
$lsblknvme 2> /dev/null
elif [[ $blk = 5 ]]; then
echo "Listing loop virtual devices"
$lsblkloop 2> /dev/null
elif [[ $blk = 6 ]]; then
echo "Listing memory device(s) into /dev/"
$lsblkmem 2> /dev/null
elif [[ $blk = 7 ]]; then
echo "Listing everything into /dev/"
$lsblkall 2> /dev/null
elif [[ =blk = * ]]; then
echo "Incorrect input / Empty input"
echo "Aborting!"
exit
elif [[ $blk = [Aa]bort ]]; then
echo "Aborting!"
exit
elif [[ -z "$blk" ]]; then
echo "Aborting!"
exit
fi
exit

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Allow user to show system files with a menu
catfstab="cat /etc/fstab"
cathostname="cat /etc/hostname"
cathosts="cat /etc/hosts"
choice=
printf '
------------------------------------------
SYSTEM CONFIG FILES MENU CHOOSER V1.0b
------------------------------------------
This script will be updated with more features,
for now, you can :
fstab : Show the fstab file
hostname : Show the hostname file
hosts : Show the hosts file
'
echo -n "Make your choice : "
read choice
if [[ $choice = fstab ]]; then
$catfstab
elif [[ $choice = hostname ]]; then
$cathostname
elif [[ $choice = hosts ]]; then
$cathosts
else
echo "Aborting!"
exit
fi

68
SH_PROJECTS/sshclientmenu.sh Executable file
View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# This script need espeak, you can install it :
# apt-get install espeak / yum install espeak
sship=0.0.0.0
sshuser=user
sftpip=0.0.0.0
sftpuser=user
mode=ssh
printf '
╔══════════════════════════╗
║ Secure SHell Client Tool ║
╚══════════════════════════╝
This tool allow you to connect
SSH Servers, SFTP Servers using
your own OpenSSH installation
(ssh/sftp command)
You can run this tool as superuser
if **REALLY** needed.
You need to run in ssh or sftp mode?
1) ssh mode (Secure Shell Console)
2) sftp mode (Secure File Transfert Protocol)
[1/2/Abort]
'
echo "Welcome" | espeak -venglish
echo
echo "Your hostname is `hostname`"
echo
echo -n "mode="
read mode
if [[ $mode = 1 ]]
then
echo -n "Target IP : "
read sship
echo -n "Target Login : "
read sshuser
echo
printf '
╔═══════════════════════════╗
║ SSH STARTED LOGIN SESSION ║
╚═══════════════════════════╝
'
echo "SSH Started Login Session" | espeak -venglish
echo
ssh $sship -l $sshuser 2> /dev/null
echo "Good Bye" | espeak -venglish
elif [[ $mode = 2 ]]
then
echo -n "Target IP : "
read sftpip
echo -n "Target Login : "
read sftpuser
echo
printf '
╔════════════════════════════╗
║ SFTP STARTED LOGIN SESSION ║
╚════════════════════════════╝
'
echo "SFTP Started Login Session" | espeak -venglish
echo
sftp $sftpuser@$sftpip 2> /dev/null
echo "Connection Closed. Good Bye !" | espeak -venglish
fi

68
SH_PROJECTS/systeminfoshow.sh Executable file
View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# This script will ask you for showing LS. but in different way, with -l, -la, and -x.
# Execute as root for more features !
# Used variable : $lschoose, $ls*
lscpu="lscpu"
lshw="lshw"
lsmem="lsmem"
lsblk="lsblk"
lshwshort="lshw -short"
lshwmemory="lshw -short -c memory"
any="echo Aborting."
lschoose=
UID_CHECK=0
printf '
-------------------------
SYSTEM INFORMATION MENU
-------------------------\n
'
echo "Make your choice : "
echo -n "
0) processor : Show CPU informations
1) hardware : Full hardware informations
2) hardwareshort : Short but powerfull informations
3) memory : RAM informations
4) memory_root : RAM informations as root
5) sysmem : RAM Full informations
6) disks : Show partitions and disks\n
Active User Informations :
UID : $UID
User : $USER
Date : `date`
Your choice [0/1/2/3/4/5/6/Abort]
"
read lschoose
if [[ $lschoose = 0 ]]; then
$lscpu
elif [[ $lschoose = 1 ]]; then
$lshw
elif [[ $lschoose = 2 ]]; then
$lshwshort
elif [[ $lschoose = 3 ]]; then
$lshwmemory 2> /dev/null
elif [[ $lschoose = 4 ]]; then
if [[ $UID = 0 ]]; then
$lshwmemory 2> /dev/null
elif [[ $UID = * ]]; then
echo "
You are not ROOT (your UID = $UID), if
you want to use this feature :
run 'sudo ./[script.sh]'
or
run 'sudo su' and then run './[script.sh]'
"
exit
fi
elif [[ $lschoose = 5 ]]; then
$lsmem
elif [[ $lschoose = 6 ]]; then
$lsblk
elif [[ $lschoose = * ]]; then
$any
fi

50
SH_PROJECTS/tracepathtester.sh Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Now, using Tracepath in the same way as Ping Tester :
local=127.0.0.1
dns=8.8.8.8
modemhome=192.168.1.1
company1=172.16.1.1
company2=10.0.1.1
company3=10.0.0.1
debug=0.0.0.0
custom=
trace=
printf '
-------------------------------
TRACEPATH MENU CHECKER V1.0
-------------------------------
Choose a way to check Tracepath/route :
local : Make a route to 127.0.0.1 (loopback/yourself)
dns : Make a route to 8.8.8.8 (Google DNS)
home : Make a route to 192.168.1.1 (Home Router or Company Router)
company1 : Make a route to 172.16.1.1 (Company network IP)
company2 : Make a route to 10.0.1.1 (Company network IP)
company3 : Make a route to 10.0.0.1 (Company network IP)
custom : Make a route to custom IP (for Company with more IP or Home
with more than one Router)
'
echo -n "Make your choice : "
read trace
if [[ $trace = local ]]; then
tracepath $local 2> /dev/null
elif [[ $trace = dns ]]; then
tracepath $dns 2> /dev/null
elif [[ $trace = home ]]; then
tracepath $modemhome 2> /dev/null
elif [[ $trace = company1 ]]; then
tracepath $company1 2> /dev/null
elif [[ $trace = company2 ]]; then
tracepath $company2 2> /dev/null
elif [[ $trace = company3 ]]; then
tracepath $company3 2> /dev/null
elif [[ $trace = custom ]]; then
echo "Enter IP : "
read $custom
tracepath $custom 2> /dev/null
else
echo "Aborting!"
exit
fi

27
SH_TRAINING/training1.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
echo "Training Script. This script use only ECHO command"
# -----------------------------------
num=
printf '
If user send "One", the script answer "Two"
If user send "Two", the script answer "Three"
If user send "Three", the script answer "Four"
If user send "Four", the script answer "Five"
If any other input is sent, the script will answer "What?"
Now, starting script !
'
sleep 1
echo -n "Enter a number in letter [One/Two/Three/Four]:"
read num
if [[ $num = [Oo]ne ]]; then
echo "Two"
elif [[ $num = [Tt]wo ]]; then
echo "Three"
elif [[ $num = [Tt]hree ]]; then
echo "Four"
elif [[ $num = [Ff]our ]]; then
echo "Five"
else
echo "What?"
fi

51
SH_TRAINING/training2.sh Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
echo "Training Script. This script use only ECHO command"
# -----------------------------------7
echo -n "What is your name ? "
read name
echo -n "What is you surname ? "
read surname
echo -n "How old are you ?"
read age
echo -n "Where do you live ?"
read live
printf '
Emotions :
------
happy
sad
hungry
tired
angry
stressed
------
'
echo -n "What is your current emotion ?"
read emo
if [[ $emo = happy ]]; then
emotion=$emo
elif [[ $emo = sad ]]; then
emotion=$emo
elif [[ $emo = hungry ]]; then
emotion=$emo
elif [[ $emo = tired ]]; then
emotion=$emo
elif [[ $emo = angry ]]; then
emotion=$emo
elif [[ $emo = stressed ]]; then
emotion=$emo
else
emotion="without any emotions"
fi
echo "---------"
sleep 1
clear
echo "Your name is $name"
echo "your surname is $surname"
echo "you are $age years old"
echo "Currently, you are $emo"
echo "and you live in $live"
echo
echo

129
SH_TRAINING/training3.sh Executable file
View file

@ -0,0 +1,129 @@
#!/usr/bin/env bash
echo "Training Script. This script use only ECHO command"
# --------------------------------------------------------------
# In this script, user send five times a number between 1 and 5.
# Results can be :
# ⩇⩇
# ⩇⩇⩇
# ⩇⩇⩇⩇
# ⩇⩇⩇⩇⩇
# ⩇⩇⩇⩇⩇⩇
# if user send 2 3 4 5 6
#
# In case of inccorect imput into any variable,
# the value will be "invalid"
# --------------------------------------------------------------
echo "
⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
⎮ The Condition Game!⎮
⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
This game will show line of '-' conditionnaly to
your choice of number. Example :
2 ⩇⩇
4 ⩇⩇⩇⩇
5 ⩇⩇⩇⩇⩇
1
3 ⩇⩇⩇
If you enter any other thing (like a word) it will show
'Value upper or equal of 6, or invalid input !'
Enter five number, for example :
1
2
3
4
5
By typing enter for each number.
--
"
echo -n "one= "
read one
echo -n "two= "
read two
echo -n "three= "
read three
echo -n "four= "
read four
echo -n "five= "
read five
echo --
echo "Choosen numbers : $one $two $three $four $five"
if [[ $one = 1 ]]; then
one=
elif [[ $one = 2 ]]; then
one=⩇⩇
elif [[ $one = 3 ]]; then
one=⩇⩇⩇
elif [[ $one = 4 ]]; then
one=⩇⩇⩇⩇
elif [[ $one = 5 ]]; then
one=⩇⩇⩇⩇⩇
else
one="Value $one is upper or equal of 6, or invalid input !"
fi
if [[ $two = 1 ]]; then
two=
elif [[ $two = 2 ]]; then
two=⩇⩇
elif [[ $two = 3 ]]; then
two=⩇⩇⩇
elif [[ $two = 4 ]]; then
two=⩇⩇⩇⩇
elif [[ $two = 5 ]]; then
two=⩇⩇⩇⩇⩇
else
two="Value $two is upper or equal of 6, or invalid input !"
fi
if [[ $three = 1 ]]; then
three=
elif [[ $three = 2 ]]; then
three=⩇⩇
elif [[ $three = 3 ]]; then
three=⩇⩇⩇
elif [[ $three = 4 ]]; then
three=⩇⩇⩇⩇
elif [[ $three = 5 ]]; then
three=⩇⩇⩇⩇⩇
else
three="Value $three is upper or equal of 6, or invalid input !"
fi
if [[ $four = 1 ]]; then
four=
elif [[ $four = 2 ]]; then
four=⩇⩇
elif [[ $four = 3 ]]; then
four=⩇⩇⩇
elif [[ $four = 4 ]]; then
four=⩇⩇⩇⩇
elif [[ $four = 5 ]]; then
four=⩇⩇⩇⩇⩇
else
four="Value $four is upper or equal of 6, or invalid input !"
fi
if [[ $five = 1 ]]; then
five=
elif [[ $five = 2 ]]; then
five=⩇⩇
elif [[ $five = 3 ]]; then
five=⩇⩇⩇
elif [[ $five = 4 ]]; then
five=⩇⩇⩇⩇
elif [[ $five = 5 ]]; then
five=⩇⩇⩇⩇⩇
else
five="Value $five is upper or equal of 6, or invalid input !"
fi
echo "Now, this is the result :
$one
$two
$three
$four
$five
"

43
SH_TRAINING/training4.sh Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
echo "
----------------------
The additions script
----------------------
"
echo
echo "Enter two value, the script will calculate them."
echo
echo -n "First : "
read first
echo -n "$first+"
read second
echo "$first+$second=`echo $(($first+$second))`"
echo "$first plus $second equal to `echo $(($first+$second))`"
echo
echo "Now, the same thing with substracting :"
echo -n "First : "
read first
echo -n "$first-"
read second
echo "$first-$second=`echo $(($first-$second))`"
echo "$first substracted to $second equal to `echo $(($first-$second))`"
echo
echo "Now, with dividing :"
echo
echo -n "First : "
read first
echo -n "$first/"
read second
echo "$first/$second=`echo $(($first/$second))`"
echo "$first divided $second equal to `echo $(($first/$second))`"
echo
echo "Now, with... Multiplication !"
echo
echo -n "First : "
read first
echo -n "$first*"
read second
echo "$first*$second=`echo $(($first*$second))`"
echo "$first multiplicated by $second equal to `echo $(($first*$second))`"
echo
echo "End of script"

View file

@ -0,0 +1,62 @@
# This is not a script
Les conditions dans un script shell type BASH et SH (qui ne sont pas pareil !) permettent de faire un choix en fonction d'un résultat de variable (par exemple, la réponse de l'utilisateur)
Ainsi, avec la condition suivante :
------------------------------------
echo -n "Choose between A, B or C :"
read answer
if [[ $answer = A ]]
then
echo "Is A letter"
elif [[ $answer = B ]]
then
echo "Is B letter"
elif [[ $answer = C ]]
then
echo "Is C letter"
fi
------------------------------------
La condition va alors :
Répondre "Is A letter" si l'utilisateur insère "A" "
Répondre "Is B letter" si l'utilisateur insère "B" "
Répondre "Is C letter" si l'utilisateur insère "C" "
Ainsi, imaginez que cette condition génére autre chose que des commandes echo, vous pourrez ainsi afficher des menus, installer des paquets, faire des pings, faire des logs, et plus encore !
------------------------------------------------------------------
La différence entre BASH et SH est simple au niveau des conditions
En effet, le SH (Shell) étant plus vieux que le BASH (Bourne Again Shell) il existe une différence de scripting au niveau des conditions.
En #!/bin/sh, on mettra alors :
if [ conditions ]
then
En #!/bin/bash, on mettra alors :
if [[ conditions ]]
then
Le SH ne supporte pas les double "[]" par exemple.
------------------------------------------------------------------
Le then, en fonction de votre Shell (bash, zsh...) le then peut se
positionner de deux façon :
if [[ conditions ]]; then
et
if [[ conditions ]]
then
Il est libre de choisir entre l'un et l'autre, en prenant en
compte que le deuxiéme est plus sûr.

13
TIPS.md Executable file
View file

@ -0,0 +1,13 @@
Vous pouvez utiliser cette astuce pour voir les commandes des scripts lors de son execution :
faire :
bash [script]
execute le script normalement.
faire :
bash -xv [script]
execute le script en debugging (avec les commandes)

20
test.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
echo "On commence"
echo
echo -n "Entrer la lettre A, B ou C : "
read var
if [[ $var = A ]]
then
echo A
elif [[ $var = B ]]
then
echo B
elif [[ $var = C ]]
then
echo C
elif [[ $var = "" ]]
then
echo "empty input"
elif [[ $var = * ]]; then
echo "$var is incorrect"
fi