From 106aede5fed9ce240d6a601fdafc629b845c7ec7 Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 00:20:16 +0530 Subject: [PATCH 1/7] color issue solved --- scripts/color | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/color b/scripts/color index d6a4fe8..939dcdc 100755 --- a/scripts/color +++ b/scripts/color @@ -1,7 +1,9 @@ #!/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" } @@ -9,7 +11,14 @@ color() { 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 From efcc1651a41d5ae0c2bc91978cb5959a49dc10d5 Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 00:42:42 +0530 Subject: [PATCH 2/7] color issue solved --- scripts/color | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/color b/scripts/color index 939dcdc..1984f11 100755 --- a/scripts/color +++ b/scripts/color @@ -3,7 +3,7 @@ #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" +echo -ne "\033[35mhello\033[0m" color() { echo -ne "\033[$1;$2m" } From 28b77d3ba3397c807909350bc815c1e8d3eed47c Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:19:41 +0530 Subject: [PATCH 3/7] wifi ssid problem solved --- scripts/wifi-ssid | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/wifi-ssid b/scripts/wifi-ssid index 29af3cc..44a2a53 100755 --- a/scripts/wifi-ssid +++ b/scripts/wifi-ssid @@ -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" From 5ea98da7347cf9a8ce7a25660110be518e283131 Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:33:16 +0530 Subject: [PATCH 4/7] wheather issue solved --- scripts/weather | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/weather b/scripts/weather index 7374d86..6343517 100755 --- a/scripts/weather +++ b/scripts/weather @@ -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 " + exit 1 +fi +curl -s wttr.in/"$location" | tr -d '\r' \ No newline at end of file From 5e985e8b47d5c7ffc6bbe19b20832b7c3135a7ba Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 02:10:19 +0530 Subject: [PATCH 5/7] add genrate function --- scripts/password-generator | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/password-generator b/scripts/password-generator index f88bbe7..5d7ca64 100644 --- a/scripts/password-generator +++ b/scripts/password-generator @@ -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" From 79b1ca5f87dae7cffdcceb1b6fad672a295e9daa Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:19:02 +0530 Subject: [PATCH 6/7] add perms script --- scripts/perms | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/perms b/scripts/perms index b683156..c9906d3 100755 --- a/scripts/perms +++ b/scripts/perms @@ -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 file" + 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 \ No newline at end of file From 4076d8083ad2846679003e81fa8d05c11a69937b Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:28:14 +0530 Subject: [PATCH 7/7] add perms script --- scripts/perms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/perms b/scripts/perms index c9906d3..24e339e 100755 --- a/scripts/perms +++ b/scripts/perms @@ -15,7 +15,7 @@ getPerms() { local permissions=$(stat -c "%a" "$file") echo "$permissions $file" else - echo "Error: this '$file' is not a regular file" + echo "Error: this '$file' is not a regular files" fi }