User Controls

Shell script thread

  1. #21
    Admin African Astronaut
    Originally posted by GGG Yeah I understand all of this and more you guys are basically coding babies lol

    print("suckmysmalldicklol")

    I prefer 'println'. I usually need the new line.
  2. #22
    Lanny Bird of Courage
    Spectral doesn't know what a shell script is lol
  3. #23
    filtration African Astronaut
    This post has been edited by a bot I made to preserve my privacy.
  4. #24
    filtration African Astronaut
    This post has been edited by a bot I made to preserve my privacy.
  5. #25
    Sophie Pedophile Tech Support
    Damn 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.
  6. #26
    Lanny Bird of Courage
    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.
  7. #27
    Soyboy V: A Cat-Girl/Boy Under Every Bed African Astronaut [my no haunted nonbeing]
    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.

    Gettin' old brother.

    ...the old ways...
  8. #28
    Sophie Pedophile Tech Support
    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.
  9. #29
    POLECAT POLECAT is a motherfucking ferret [my presentably immunised ammonification]
    b 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
  10. #30
    Sophie Pedophile Tech Support
    Originally posted by POLECAT b 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

    I commend your mom's commitment to the craft.
  11. #31
    POLECAT POLECAT is a motherfucking ferret [my presentably immunised ammonification]
    she was a determined woman
  12. #32
    Lanny Bird of Courage
    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.
  13. #33
    filtration African Astronaut
    This post has been edited by a bot I made to preserve my privacy.
  14. #34
    Sophie Pedophile Tech Support
    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.
  15. #35
    nice resources for beginner bash scripters:

    https://github.com/onceupon/Bash-Oneliner/blob/master/README.md

    https://github.com/LeCoupa/awesome-cheatsheets/blob/master/languages/bash.sh

    https://github.com/dylanaraps/pure-bash-bible/blob/master/README.md
  16. #36
    mashlehash victim of incest [my perspicuously dependant flavourlessness]
    good thread
  17. #37
    Sophie Pedophile Tech Support
    Now 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.
  18. #38
    Sophie Pedophile Tech Support
    Also, you'll need coreutils, or else you won't have things like shred.
  19. #39
    mashlehash victim of incest [my perspicuously dependant flavourlessness]
    ty again btw
  20. #40
    Bugz Space Nigga
    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
    The following users say it would be alright if the author of this post didn't die in a fire!
Jump to Top