r/ScriptSwap • • Mar 30 '18

New Script for installation

1 Upvotes

So I am trying to automate a process as much as possible. I've only been working with scripts about a month so they are very messy and I feel like they are all over the place. I'm looking for some assistance on two scripts in particular, uninstalling Win10 Update Assis., mounting an ISO to F: and running executable to install 4 applications in order then dismount the ISO from F: then delete the executable from the desktop. I'm open to any suggestions outside of letting my end-user run the setup of each application. Here is what I have so far

@echo off

c:\Windows10Upgrade\Windows10UpgraderApp.exe /ForceUninstall Del C:\Windows\UpdateAssistant*.* /F /Q

Mount-DiskImage C:\Users\Tech\Desktop\Office.ISO

start "" /w /b "c:\Users\Tech\Desktop\Firefox Installer.exe" start "" /w /b "c:\Users\Tech\Desktop\readerdc_en_xa_install.exe" start "" /w /b "f:\setup.exe" start "" /w /b "c:\Users\Tech\Desktop\Antivirus\Setup.exe"

Dismount-DiskImage -ImagePath "C:\Users\Tech\Desktop\Office.ISO" ECHO F | del /s /q /f "c:\Users\Tech\Desktop\Firefox Installer.exe" ECHO F | rd /s /q "c:\Users\Tech\Desktop\Antivirus" ECHO F | del /s /q /f "c:\Users\Tech\Desktop\Office.ISO" ECHO F | del /s /q /f "c:\Users\Tech\Desktop\ITDeptAdmin.txt ECHO F | del /s/ q /f "c:\Users\InstTech\Desktop\installertest.bat" ECHO F | del /s /q /f "c:\Users\InstTech\Desktop\finishinstalltest.bat"

rd /s %systemdrive%$Recycle.bin


r/ScriptSwap • • Dec 31 '17

[Ruby] Zip a directory

1 Upvotes

this again is an update of the compression script in "Wicked Cool Ruby Scripts". It uses RubyZip.

#!/usr/bin/env ruby
#
# zipruby.rb
# 2017-12-30

require 'zip'
require 'find'

# the script exits unless two arguments are given
unless ARGV.length == 2
  puts "Error: number of arguments incorrect"
  puts "Usage: zipruby.rb <output.zip> <input.dir>"
  exit
end

# the script exits if the second argument is not a directory
dir = ARGV[1].chomp
unless File.directory?(dir)
  puts "Error: #{dir} is not a directory"
  puts "Usage: zipruby.rb <output.zip> <input.dir>"
  exit
end

# script exits if the output file exists
zip = ARGV[0].chomp
if File.exist?(zip)
  puts "Error: #{zip} already exists"
  puts "Usage: zipruby.rb <output.zip> <input.dir>"
  exit
end

 ARGV.clear

Zip::File.open(zip, Zip::File::CREATE) do |zipfile|
  Find.find(dir) do |file|
    next unless File.file?(file)
    zipfile.add(file, file)
    puts "adding #{file} to archive..."
  end
end

r/ScriptSwap • • May 26 '14

Download subreddit information[X-Post]

1 Upvotes

Original link: http://www.reddit.com/r/redditlists/comments/26hkam/completed_subreddit_enumeration_script/

" Completion of: http://www.reddit.com/r/redditlists/comments/26372o/list_of_every_subreddit/ I finally completed a script that allows you to download a list of every subreddit and put them into one file. This script also allows you to extract how many people are subscribed as well as their description. There is also a feature to download a pdf, png, jpeg (what ever file format you'd like for visual appeal) of the front page of the website. 3 things I'm still missing however, 1. Where should I upload this script? Where would be the appropriate place? 2. What other feature should I add to this? 3. What subreddit should this script be presented to (if any) that could be beneficial? (something like /r/datasets, etc.) Also, it is written in Bash.

"


r/ScriptSwap • • May 07 '14

My first program have a look,

1 Upvotes

here is my first program, check it out advice is all appreciated!

https://sourceforge.net/projects/hphelpful/


r/ScriptSwap • • Jul 01 '13

[REQUEST] [BAT] Mass software upgrade, would like help scripting the config file backup

1 Upvotes

Ok, so the story is I have to bring a client from their Lotus Notes installs from 2009 & 2010 to the latest version en masse. I have the install itself scripted but have to backup files. Some computers have the config files in "%programfiles%\IBM\Lotus\Notes\Data" (OR if it's x64 it's the (x86) program files and some have it in "%appdata%\Lotus\Notes\Data".

I have the copying taken care of, but want help checking which directory it's in, especially because after I have to copy the files back.

Not sure if BAT files are even versatile enough for checking if those directories exist and, if so, setting the rest of the script to use them.

So Far.. Any help much appreciated.

Edit: Formatting


r/ScriptSwap • • May 22 '13

Reddit Titles Scraper

1 Upvotes

Based on the first draft of this post (http://www.reddit.com/r/r4r/comments/1eue1y/meta_browse_r4r_with_a_shell_script/ ) I did some clean-ups and reworking into something that should be fairly portable across the rest of redditspace.

There's plenty of room for adding additional functionality, but for now it's a simple script that scrapes the titles from any subreddit, between 1 and 30 (max 10) pages deep, and can also apply a regex filter against the titles.

It's particularly fun because of the redirection games played within the loop's subshell, and demonstrates an interesting use of tee, i think.

!----8<

#!/bin/bash
PROG="${0##*/}"

# Default subreddit
REDDIT=r4r
# Default filter
FILTER="."

#################
usage() {
    echo "${PROG}: [-n #pages] [-r reddit] [-i] [-f filter]"
    echo ""
    echo "        -n #pages         search n pages deep"
    echo "        -r reddit         search specified reddit instead of default (${SUBREDDIT})"
    echo "        -f filter         quoted regex filter, case insensitive (ex: -f '(M4[TFARM]|F4F)' )"
    echo "        -i                invert/negate the filter"
    echo ""
}

while getopts "n:r:f:hi" param; do
  case $param in
    n) MAXPAGE=$OPTARG ;;
    r) REDDIT=${OPTARG//.*\/r\//} ;;
    f) FILTER="${OPTARG}" ;;
    i) INVERT="-v" ;;
    h) usage; exit 0;;
    *) usage; exit 1;;
  esac
done

REDDIT=${REDDIT//\//}
SUBREDDIT="http://www.reddit.com/r/${REDDIT}/"
MAXPAGE=${1:-10}
MAXPAGE=${MAXPAGE//[^0-9]/}
test ${MAXPAGE} -gt 30 && MAXPAGE=30
    
for page in $(seq 1 ${MAXPAGE})
do
    SUBREDDIT=$( wget -nv -O - $SUBREDDIT 2>/dev/null | \
            sed 's|<|\n<|g; s|>|>\n|g' | \
            egrep -A1 'class=\"title \"|r4r/\?count.*after' | \
            sed 's/.*href="\(.*\)" rel.*/\1/' | \
            egrep -v "^(\-\-|<a|next|/r)" | \
            tee >(grep -v http 1>&2) | grep http )

done 2>&1 |  egrep -i ${INVERT} "${FILTER}"

>8-------

*edits because I'm an dum bass


r/ScriptSwap • • Apr 25 '13

[Python] SSH Honeypot

1 Upvotes

Just a small script I run on my server for fun. Enjoy!

https://github.com/hauk142/SSHTroll


r/ScriptSwap • • Jul 12 '12

GoDaddy & DDNS PHP script

1 Upvotes

I haven't used it but it looks promising for my needs. This may severe the terms and conditions with GoDaddy, not sure yet, more research is needed.

https://github.com/Stanback/GoDaddy-DDNS-PHP/blob/master/godaddy-ddns.php

http://www.stanback.net/code/godaddy-dyndns.html


r/ScriptSwap • • Jun 08 '12

[perl] git2ftp -- a simple script that will ftp all the files changed in your latest git commit to a location of your choosing

1 Upvotes

r/ScriptSwap • • May 11 '12

[Perl/Linux]: dmesg's seconds since boot -> human time (on each line)

1 Upvotes

If you're trying to diagnose a problem on a server and "dmesg" tells you something interesting (e.g. oom-killer, nfs problems, eth problems) but you want to know if the messages are recent or from weeks ago but it's hard to tell at a glance because dmesg tells you when it happened with a number meaning "seconds since boot". This script reads the output of dmesg and prefixes each line with a time like "2012-05-10 22:33:57 " which is the "seconds since boot" added to the boot time. git

#!/usr/bin/perl -w

# dmesg on modern kernels prefixes each line with the number of seconds since boot.
# This script determines the boot time and turns the 'seconds' since boot to a (local) human time. 
# So instead of seeing
# [60456.816070] Out of memory: kill process 1272 (foo) score 232078 or a child
# you get
# 2012-05-11 05:30:24 [60456.816070] Out of memory: kill process 1272 (foo) score 232078 or a child

use strict;
use DateTime;
use 5.010;

sub get_dt_now {
    my $dt;
    for my $tz ('local', 'America/Toronto', 'EST5EDT') {
        eval { $dt = DateTime->now( time_zone => $tz ); };
        return $dt unless $@;
    }
    return DateTime->now(); # if no perferred time zone found.. default to UTC
}

sub get_dt_boot {
    if ( -e '/proc/uptime' ) {
        if ( open(my $uptime, '<', '/proc/uptime') ) {
            my $line = <$uptime>;
            my ($seconds_since_boot, $idle_seconds) = split(/\s+/, $line);
            my $dt = get_dt_now();
            $dt->add( seconds => -$seconds_since_boot );
            close($uptime);
            return ($dt, 0);
        }
    }
    # rely on `uptime` implies only 'minute' accuracy, no data for seconds. :(
    my $uptime_str = `uptime`;

    die "no /proc/uptime and uptime returned an unexpected format $uptime_str" unless $uptime_str =~
        /^
            \s*
            \d\d:\d\d:\d\d # 'now' as reported by uptime.. ignore it
            \s+up\s+
            (?:
                (?:(?<n_days>\d+)\s+days,\s+)?(?<off_h>\d?\d):(?<off_m>\d\d)
            |
                (?<n_min>\d+)\s+min,
            )
        /x;

    my $dt = get_dt_now();
    $dt->add( days    => -$+{n_days} ) if $+{n_days};
    $dt->add( hours   => -$+{off_h } ) if $+{off_h};
    $dt->add( minutes => -$+{off_m } ) if $+{off_m};
    $dt->add( minutes => -$+{n_min } ) if $+{n_min};

    return ($dt, 'WARNING: boot time is only known to within a minute, so all all human legible times can be off by a minute' );
}

sub main {
    my ($dt_boot, $warning) = get_dt_boot();
    print "Booted at " . $dt_boot->ymd() . ' ' . $dt_boot->hms() . "\n";

    open(my $dmesg, '-|', 'dmesg') || die "Could not call dmesg: $!";
    while(<$dmesg>) {
        if ( /^\[\s*(\d+)\.\d+\s*\]/ ) {
            my $dt = $dt_boot->clone()->add( seconds => $1 );
            if ( $warning ) {
                printf("%s %02d:%02d %s", $dt->ymd, $dt->hour, $dt->min, $_);
            } else {
                print $dt->ymd . ' ' . $dt->hms . ' ' . $_;
            }
        } else {
            print;
        }
    }
    print "TimeZone = " . $dt_boot->time_zone->name . "\n";
    print "$warning\n" if $warning;
}

main();

r/ScriptSwap • • May 06 '12

[bash] simple indexing program

1 Upvotes

This program is a series of indexing scripts to quickly index all the files of you computer, and search the index very quickly. It has an output mode that is friendly to other programs, as well as one that is good for the command line. The index files are very small and are human readable. They can be searched very quickly (mush faster than the find command) but need to be updated.

Download: https://www.dropbox.com/s/1zta3o8s7p8wtes/indexers.zip

sorry it is a dropbox address, mediafire is broken. Uploaded because of multiple files.

Usage:

use the -q flag before the search term to make the output script friendly.

cdindex-make: makes index of current directory
cdindex: searches current directory index made by cdindex-make

rootindex-make: makes index of /
rootindex: searches / index made by rootindex-make

index-make: makes index of your home folder
index: searches home folder index made by index-make

getlines.py: must be in same folder as other executables. (works in /usr/bin or another directory)

Credit to Rhomboid.


r/ScriptSwap • • Mar 21 '12

[vi / cvs / Perl] cvsBlame.pl shows cvs annotations and commit log message via one key from vi.

1 Upvotes

Based on this idea from OneAndOneIs2 which lets you see git blame information from within vi, this script does the same but for CVS.

You put this in your ~/.vimrc

" This goes into your ~/.vimrc
nmap <f4> :call BlameCurrentLine()<cr>
" Get the current file name and line number, pass them to cvsBlame.pl
fun! BlameCurrentLine()
    let lnum = line(".")
    let file = @%
    exec "!cvsBlame.pl " file lnum
endfun 

And put cvsBlame.pl git in your path. Then when you hit F4 you see something like

    30 1.214        (someuser 30-Apr-04): use Date::Manip;
    31 1.402        (user2    11-Jan-08): use DateTime;
    32 1.292        (someuser 28-Apr-05): use Date::Calc qw(check_date);
    33 1.2          (someuser 29-Aug-01): use DBI;
    34 1.2          (someuser 29-Aug-01): use DBD::Oracle;
*   35 1.214        (someuser 30-Apr-04): use Fcntl;
    36 1.214        (someuser 30-Apr-04): use Forker;
    37 1.240        (user3    10-Aug-04): use Email::Valid;
    38 1.214        (someuser 30-Apr-04): use Logger;
    39 1.214        (someuser 30-Apr-04): use Core::Logger;
    40 1.214        (someuser 30-Apr-04): use Core::Config;
revision 1.214
date: 2004-04-30 10:02:04 -0400;  author: someuser;  state: Exp;  lines: +758 -232
some_branch merged into main and closed
=============================================================================

r/ScriptSwap • • Mar 21 '12

Create desktop launchers in unity [BASH]

1 Upvotes

The unity UI can be a bit tricky at times, and after giving it a go today, I can't find a way of creating desktop launcher, so I made this


#!/bin/bash

echo "Ok, let's create a desktop launcher"
echo "Pick a name for this launcher so we can recognize it on the desktop:"
echo -en "name> "
read launcherName
echo "Ok, now enter the full path of the script you want to execute"
echo -en "script> "
read launcherScript
echo "#!/usr/bin/env xdg-open

[Desktop Entry]Name[en_IE]=$launcherName

Version=1.0
Type=Application
Terminal=false
Exec=$launcherScript
Name=$launcherName
Icon=/usr/share/icons/gnome/48x48/emotes/face-wink.png" >~/Desktop/$launcherName.desktop

chmod a+x ~/Desktop/$launcherName.desktop

The icon should appear on your desktop with a winky face.

Surely this is an easier way around this? I haven't really bothered googling much, because my internet connection is very slow...


r/ScriptSwap • • Mar 19 '12

Can we make it a policy about pastebins to use?

1 Upvotes

pastebin.com is full of ads and random javascript and formatting crap. I sometimes have a hard time opening it, and I know it is blocked for others. I would like to request that we use pastebins like paste.pocoo.org hpaste.org codepad.org pastie.org gist.github.com dpaste.de or sprunge.us?

just a thought, thanks


r/ScriptSwap • • Mar 02 '12

sshfs mount and umount using kdialog

1 Upvotes

Description: SSHFS is very cool and makes it great for working with files on servers. In my case i use vms for web development and mount a server, open my editor and start programming away. It beats trying to use a file manager to sftp/ssh/fish into a server. How to setup and use: Put a list of servers in the script. Launch it and Kdialog chooser pops up. Pick your server and it mounts. !/bin/bash variable=kdialog --menu "MOUNT:" A "SERVERNAME1" B "SERVERNAME2" C "SERVERNAME3";; if [ "$?" = 0 ]; then if [ "$variable" = A ]; then sshfs user@ip:/server/location /user/local/location elif [ "$variable" = B ]; then sshfs user@ip:/server/location /user/local/location /home/scott/mount/sisaddons elif [ "$variable" = C ]; then sshfs user@ip:/server/location /user/local/location else echo "ERROR"; fi; else echo "YOU CHOSE CANCEL"; fi;

To remove the connection: You can copy and make a new bash file and replace the lines accordingly: All you change is the sshfs user@ip line with fusermount -u /user/local/location This will remove the connection. These could be one script with command line arguments. For those in a GTK environment you can easily make it use GDialog. I know there is a XDialog and some more universal simple Dialogs that would work. I picked KDialog because i use KDE and Like Qt.


r/ScriptSwap • • Mar 02 '12

upload text to sprunge.us - works in pipelines, too! [public domain]

1 Upvotes
#!/bin/sh
if [ -z "$1" ]
then
    exec curl -s -F 'sprunge=<-' http://sprunge.us
else
if [ -z "$2" ]
    then
        echo -n "$1:"
        cat "$1" | "$0"
    else
    for i in "$@"
    do
        "$0" "$i"
    done
fi

fi


r/ScriptSwap • • Mar 02 '12

Pause Compiz While Game Runs

1 Upvotes

Pretty basic...just replaces Compiz with metacity. This flicker issue I had ~4+ years ago may not be an issue any more so this script might be irrelevant at this point

#!/bin/bash
 
#pre-reqs
 
#Check arguments of command
if [ -z "$1" ] || [ -z "$2" ]; then
	echo ""
	echo ""
	echo "Usage is startgame  "
	echo ""
	echo " argument accepts:"
	echo "        -wine : The game requires wine"
	echo "        -nowine : The game does not require wine"
	echo ""
	echo " is path to the game when wine is used or accepts the command for linux games"
	echo ""
	echo ""
	echo "Example (Windows Game with wine): "
	echo "             startgame -wine \"/home/user/.wine/drive_c/Program Files/EAGames/game.exe\""
	echo ""
	echo "Note: If your windows game takes arguments, put it inside the quotes after the .exe (Ex: \"game.exe -quickstart\")"
	echo ""
	echo "Example (Linux game, no wine):"
	echo "             startgame -nowine frozenbubble"
	echo ""
	echo ""
 
	exit 0
fi
 
#Check if metacity exists
function checkmetacity {
	meta=`which metacity`
	if [ -n "$meta" ]; then
		echo "Metacity found."
	elif [ -z "$meta" ]; then
		echo "Metacity NOT found."
		exit 0
	fi
}
 
#Check if compiz exists
function checkcompiz {
	comp=`which compiz`
	if [ -n "$comp" ]; then
		echo "Compiz found."
	elif [ -z "$comp" ]; then
		echo "Compiz NOT found."
		exit 0
	fi
}
 
function checkwine {
	winecmd=`which wine`
	if [ -n "$winecmd" ]; then
		echo "Wine found"
	elif [ -z "$winecmd" ]; then
		echo "Wine not found.  Can not start game."
		exit 0
	fi
}
 
#Call the functions
checkmetacity
checkcompiz
 
#Start the magic
 
count=`ps -A | grep -ic compiz`
if [ $count -gt 0 ]; then
	echo "*** NOTIFICATION: Compiz found. Replacing with metacity. ***"
	echo "*** NOTIFICATION: Killing all instances of Compiz. ***"
 
	#Kill Compiz
	killall compiz.real
	if [ $? -eq 0 ]; then
		echo "*** NOTIFCATION: Killed compiz successfully. ***"
		echo "*** NOTIFCATION: Replacing with metacity. ***"
 
		#Run metacity in its place
		metacity --replace &;
		if [ $? -eq 0 ]; then
			echo "*** NOTIFCATION: Metacity ran successfully. ***"
 
			# Run game
			if [ $1 = "-wine" ]; then
				checkwine
				wine $2
			elif [ $1 = "-nowine" ]; then
				$2
			fi
 
			#Return compiz
			compiz --replace &;
			sleep 1
			exit 0
		else
			echo "*** WARNING: Could not run metacity. EXITING! ***"
			exit 0
		fi
	else
		echo "*** WARNING: Compiz was not killed successfully. ***"
		exit 0
	fi
elif [ $count -eq 0 ]; then
	echo "Compiz not found. Exiting!"
	exit 0
fi
 
exit 0

And here it is on my site http://ckozler.net/?p=27


r/ScriptSwap • • Mar 02 '12

Proposed amendment to the rules: You only have to post plain text if your script is one file.

1 Upvotes

I like the plain text rule but it seems that a lot of stuff people come up with is pretty complex. For them it is a bit ludicrous to write out complete instructions on how to build a file hierarchy when they could just post the github link.

For one file scripts though it definitely makes more sense to just post plaintext.


r/ScriptSwap • • Mar 02 '12

Simple but one of my favs - default printer

1 Upvotes

We have large reports that are generated and printed nightly. After seeing the wasted paper I decided printing to PDF printer would be better. The problem was that the user kept forgetting to change her default printer to the PDF before going home for the night.

Enter the set default printer script and Windows Task Scheduler. Runs at 5:30PM - after user has gone home, and then a separate version runs at 7:30AM - just before the user returns to the office. Anything printed at night to PDF and anything during the day to the HP LJ 1000 - without any user intervention.

Like I said simple, but I thought worth passing along.

Option Explicit Dim objNetwork, strLocal strLocal = "Adobe PDF" Set objNetwork = CreateObject("WScript.Network") objNetwork.SetDefaultPrinter strLocal WScript.Quit


r/ScriptSwap • • Mar 01 '12

Network Repair Script

1 Upvotes

I work part time in a computer repair/retail shop and frequently customers come in with malware infested computers that can't get online. I wrote this script to solve the majority of issues:

https://docs.google.com/document/d/1H14IwlBlFP0GaqjTFzIRGKQ7LIVkhc9ZY4EmXkugph0/edit

(formatting goes funny when posted directly)


r/ScriptSwap • • Mar 01 '12

sudo make me a sandwich

1 Upvotes

me: @if test $(USERNAME) = "root"; then echo "OKAY."; else echo "WHAT?"; fi

a: @if test $(USERNAME) != "root"; then echo "MAKE IT"; fi

sandwich: @if test $(USERNAME) != "root"; then echo "YOURSELF."; fi


r/ScriptSwap • • Apr 27 '25

Is this the official site of Delta for scripts?

0 Upvotes

I'm curious to know of this website link: https://delta-executor.com/ is the official Delta executor for scripts on blox fruit and other games.


r/ScriptSwap • • Aug 05 '24

STFC

0 Upvotes

Star Trek Fleet Command, is a game by Scopely. I really need to automate some functions of the gameplay. Willing to pay upon proof of function.


r/ScriptSwap • • Apr 06 '24

Breaking News: Liber8 Proxy has released Anti-Detect Virtual Machines with Anti-Detect & Residential Proxies. OS Windows & Kali, enabling users to create multiple users on their Clouds, each User with Unique Device Fingerprints, Unlimited Residential Proxies (Zip Code Targeting) and RDP/VNC Access.

Thumbnail
self.proxy_vpn
0 Upvotes

r/ScriptSwap • • Jan 05 '24

Gmail Bot, Multi-threaded mass gmail creator

0 Upvotes

The script is capable of opening multiple browser windows (you can choose headless), and it will start creating Gmail each with a different IP (provided proxy list by you).

Supports 3 different number provider (onelinesim, smsactivate and 5sim)

Here is a video of how it works https://youtu.be/e2-bArMwtTE?si=zHvEy8D9cZoEVrvv

Open for sale. Reply below with your offering price.