sdfsd
This commit is contained in:
68
super_tool.sh
Normal file
68
super_tool.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
while true; do
|
||||
echo
|
||||
echo "MENU"
|
||||
echo "1) Info about current user and OS version"
|
||||
echo "2) List files"
|
||||
echo "3) Create file"
|
||||
echo "4) Ping "
|
||||
echo "0) Exit"
|
||||
echo "================"
|
||||
read -r -p "Make your choice, Mr.Freeman: " choice
|
||||
|
||||
case "$choice" in
|
||||
1)
|
||||
echo
|
||||
echo "User: $(id -un)"
|
||||
echo "UID : $(id -u)"
|
||||
echo "Groups: $(id -Gn)"
|
||||
echo "OS version:"
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
echo "${PRETTY_NAME:-unknown}"
|
||||
else
|
||||
uname -sr
|
||||
fi
|
||||
;;
|
||||
|
||||
2)
|
||||
echo
|
||||
echo "Directory: $HOME"
|
||||
echo "Files:"
|
||||
ls -la "$HOME"
|
||||
;;
|
||||
|
||||
3)
|
||||
echo
|
||||
read -r -p "Enter directory path: " dir
|
||||
read -r -p "Enter file name: " fname
|
||||
read -r -p "Enter permissions (like 777 or smth): " perms
|
||||
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
echo "Error: directory does not exist"
|
||||
else
|
||||
path="$dir/$fname"
|
||||
touch "$path" 2>/dev/null || { echo "Error: cannot create file"; continue; }
|
||||
|
||||
chmod "$perms" "$path" 2>/dev/null || { echo "Error: chmod failed"; continue; }
|
||||
|
||||
echo "Created"
|
||||
fi
|
||||
;;
|
||||
|
||||
4)
|
||||
echo
|
||||
read -r -p "Enter host: " host
|
||||
ping -c 3 "$host"
|
||||
;;
|
||||
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Wrong option"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user