Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Permscript #103

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/color
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#!/usr/bin/env bash

# TODO (Run this script as): color magenta && echo hello && color reset

#The sequence \033[35m sets the color to magenta
#and the sequence \033[0m resets the color to default
echo -ne "\033[35mhello\033[0m"
color() {
echo -ne "\033[$1;$2m"
}

declare -A color_mapping=(
# TODO: Add more color values
# Refer bash color codes
['black']=30
['red']=31
['green']=32
['yellow']=33
['blue']=34
['magenta']=35
['white']=37

)

if [[ $1 == 'reset' ]]; then
Expand Down
19 changes: 19 additions & 0 deletions scripts/password-generator
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@
# Issue: Implement Password Generation Functions
# Description:
# Create a function that generates passwords, The password should consist of uppercase letters, lowercase letters, numbers, and special characters. The function should take in a single argument, which is the length of the password to generate. The function should return the generated password.

generate(){
local length="$1"
local characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"

# ensure that minimum lenth is 4
length=$(( length >= 4 ? length : 4 ))

# genrate password script
password=$(head /dev/urandom | tr -dc "$characters" | fold -w "$length" | head -n 1)

#return the genrated password
echo "$password"
}

#print the passord of length $1
input_length="$1"
password=$(generate "$input_length")
echo "Generated password: $password"
19 changes: 19 additions & 0 deletions scripts/perms
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@
# 775 weather
# 664 ../README.md


#this function print the permission in octal format
getPerms() {
local file="$1"
if [[ -f "$file" ]]; then
local permissions=$(stat -c "%a" "$file")
echo "$permissions $file"
else
echo "Error: this '$file' is not a regular files"
fi
}

# it get the file from path variable
files=("$@")

# it loopp through the file and print permissions
for file in "${files[@]}"; do
get_perms "$file"
done
6 changes: 6 additions & 0 deletions scripts/weather
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

# TODO: Display weather of IIIT, Lucknow
# For more information see: https://wttr.in/:help
location="$1"
if [[ -z "$location" ]]; then
echo "Usage: $0 <location>"
exit 1
fi
curl -s wttr.in/"$location" | tr -d '\r'
9 changes: 9 additions & 0 deletions scripts/wifi-ssid
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@

# Extract the wifi username (SSID)
# Refer: "iw dev wlan0 link" command output for this

ssid=$(iw dev wlan0 link | grep "ssid" | awk '{print $2}')

if [[ -z "$ssid" ]]; then
echo "Could not find SSID"
exit 1
fi

echo "Your WiFi username (SSID): $ssid"