User Controls
Shell script thread
-
2019-03-12 at 12:27 AM UTC
-
2019-03-12 at 3:19 AM UTCSpectral doesn't know what a shell script is lol
-
2019-03-12 at 9:18 PM UTCThis post has been edited by a bot I made to preserve my privacy.
-
2019-03-12 at 9:20 PM UTCThis post has been edited by a bot I made to preserve my privacy.
-
2019-03-16 at 3:56 PM UTCDamn Windows wizards.
Objectively, Windows and related everything is on a more deeper and fundamental level, harder than Linux. I like to bash(No pun intended) Windows, but it's pretty convoluted. One wonders why.
Also, anyone else a little sad Python 2.7 is getting shitcanned come 2020? I mean, Python 3 is nearly the same but i feel some nostalgia for it, and it's not even 2020 yet. -
2019-03-17 at 3:24 AM UTC
Originally posted by Sophie Also, anyone else a little sad Python 2.7 is getting shitcanned come 2020? I mean, Python 3 is nearly the same but i feel some nostalgia for it, and it's not even 2020 yet.
I am. I've written on here before about how py3's API "improvements" particularly around strings and core module organization aren't improvements at all. -
2019-03-17 at 6:37 AM UTC
-
2019-03-17 at 11:18 AM UTC
Originally posted by Lanny I am. I've written on here before about how py3's API "improvements" particularly around strings and core module organization aren't improvements at all.
Good to know, i wonder how long i can get away with ignoring Python 3 and stubbornly using 2.7 for everything before everyone gets mad at me. -
2019-03-17 at 11:58 AM UTCb ack in the late 80's my mom locked herself in the office for 6 weeks to learn how to use her new computer, pretty sure she was learning to code just to use the damn thing
-
2019-03-17 at 12:35 PM UTC
-
2019-03-17 at 1:02 PM UTCshe was a determined woman
-
2019-03-17 at 9:16 PM UTC
Originally posted by Sophie Good to know, i wonder how long i can get away with ignoring Python 3 and stubbornly using 2.7 for everything before everyone gets mad at me.
I think not that much longer unfortunately, or at least for me since ignoring py3 has been my plan and it doesn't look like it's going to work much longer. Major libraries are dropping or planning to drop py2 support in the not-too-distant future, Django is the one that's going to force me to migrate ISS to py3 but you're starting to see libraries crop up now that just don't have support for 2.7. -
2019-03-17 at 9:38 PM UTCThis post has been edited by a bot I made to preserve my privacy.
-
2019-03-17 at 10:28 PM UTC
Originally posted by Lanny I think not that much longer unfortunately, or at least for me since ignoring py3 has been my plan and it doesn't look like it's going to work much longer. Major libraries are dropping or planning to drop py2 support in the not-too-distant future, Django is the one that's going to force me to migrate ISS to py3 but you're starting to see libraries crop up now that just don't have support for 2.7.
fug...
Originally posted by filtration Y'all need to move to F#… shit's native to linux now too. So yeah.
Also, i gotta get C# down before i start on F#. Basically i only recently started seriously looking at the dot NET languages. -
2020-04-11 at 1:19 PM UTC
-
2020-04-11 at 1:53 PM UTCgood thread
-
2020-04-14 at 5:18 PM UTCNow that i actually can shell script with the best of them i figured i'd share.
#!/bin/bash
# Coloring scheme for notfications
ESC="\x1b["
RESET=$ESC"39;49;00m"
RED=$ESC"31;01m"
GREEN=$ESC"32;01m"
# Warning
function warning() {
echo -e "\n$RED [!] $1 $RESET\n"
}
# Green notification
function notification() {
echo -e "\n$GREEN [+] $1 $RESET\n"
}
function file_ops(){
printf "Please be patient while we collect relevant files..."
cwd=$(pwd)
cd $output
mkdir Archive
# Set up array to copy relevant files
while IFS= read -d $'\0' -r file ; do
file_list=("${file_list[@]}" "$file")
# Uncomment third line down from to force the script to look for log files instead
# Change from root directory to one of your preference if you need to
#done < <( sudo find / -name "*.log" -print0)
done < <( sudo find / -mmin -60 -print0)
notification "All relevant data has been collected, processing..."
# Copy files to the specified Dir + temporary Archive directory
for file in "${file_list[@]}"
do
sudo cp -p -f $file -t Archive
done
notification "Archiving data with password..."
cd Archive
7z a results.7z * -p
mv results.7z ..
read -p "Secure delete 'Archive' files and dir? [Y/n]: " choice
if [[ $choice == 'y' || $choice == 'Y' ]]; then
# Shred files and delete Archive dir
cd ..
find Archive -depth -type f -exec shred -v -n 1 -z -u {} \; && rm -rf Archive
sleep 1 && clear
cd $cwd
notification "All operations completed."
exit 0
else
cd $cwd
notification "All operations completed."
exit 0
fi
}
# Funtion to handle operations related to a provided directory that does not exist
function dir_ops(){
read -p 'Create directory? [Y/n]: ' choice
if [[ $choice == 'y' || $choice == 'Y' ]]; then
mkdir $output
stat $output || warning "Could not create directory. Exiting" && exit 0
file_ops
else
warning "Aborted..."
exit 0
fi
}
# Starting function
function main(){
printf "%b\nWelcome.
This script will copy all files and dirs that were
altered in the last hour to a directory of your
choosing and store them in an encrypted archive.\n\n\n"
read -p 'Enter full path to output location : ' output
printf "%b\n\n"
notification "Checking output location..."
stat $output || dirstat=0
if [[ $dirstat == 0 ]]; then
dir_ops
fi
notification "Directory checked, proceeding with file operations..."
sleep 2
# Call file operations function
file_ops
}
# Check for root
if [[ "$EUID" -ne 0 ]]; then
warning "It is recommeded the script is run as root"
read -p 'Continue without root? [Y/n]: ' choice
if [[ $choice == 'y' || $choice == 'Y' ]]; then
main
else
exit 0
fi
else
main
fi
This shell script finds all files that were changed within an hour, creates and moves the files to a special directory, archives them in an encrypted 7z after prompting you for a password. Then it shreds the original.
Also, after i build the array to copy the files i want i got a commented line a bit down. Uncomment that one and comment out the active one to force the script to look for .log files instead and perform the same operations on those. Set the starting point for the search operation to suit your needs.
EDIT: Fixed the indentation. -
2020-04-14 at 6:38 PM UTCAlso, you'll need coreutils, or else you won't have things like shred.
-
2020-12-01 at 2:45 PM UTCty again btw
-
2020-12-01 at 5 PM UTC
Originally posted by Lanny Spectral doesn't know what a shell script is lol
he explained javascript was an encryption shell for the script itself.
isn't a shell script what is written to read the core language to create command lines before an application base can start? like the encryption decryption not only is a secure tool (key) but also is like a compression tool as well. to save data space