This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant Box Updater | |
This script updates Vagrant boxes on your machine to the latest version, one at a time. It removes all versions of each box before updating to the latest version. | |
Usage: | |
1. Open a terminal window. | |
2. Navigate to the directory where the script is located. | |
3. Make the script executable: chmod +x vagrant_box_updater.sh | |
4. Run the script: ./vagrant_box_updater.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This small script will create 1million random numbers and push that to MySQL DB | |
import secrets | |
import pymysql | |
connection = pymysql.connect(host='dbserver.ourdomain.com', | |
user='dbuser', | |
password='dbpasswod', | |
db='DBNAME', | |
charset='charset', | |
port=3306, | |
cursorclass=pymysql.cursors.DictCursor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pexpect | |
child = pexpect.spawn ('ssh username@xxx.xxx.xxx.xxx -o StrictHostKeyChecking=no') | |
child.expect ('Password:') | |
child.sendline('mysupersecret\n') | |
child.expect ('.*>') | |
child.sendline ('show Hostname\n') | |
child.expect('>') | |
print child.before | |
child.expect('>') | |
child.sendline ('set HostName EDGE-Device\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pexpect | |
child = pexpect.spawn ('mysql -umyuser -pmysupersecret -hxxx.xxx.xxx.xxx') | |
child.expect ('mysql> ') | |
child.sendline ('show databases;\n') | |
child.expect ('mysql> ') | |
print child.before | |
child.expect('mysql> ') | |
child.sendline ('show processlist;') | |
child.expect ('mysql> ') | |
print child.before |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pexpect | |
child = pexpect.spawn ('ftp ftp.freebsd.org') | |
child.expect ('Name .*: ') | |
child.sendline ('anonymous') | |
child.expect ('Password:') | |
child.sendline ('me@mydomain.com') | |
child.expect ('ftp> ') | |
child.sendline('cd /pub/FreeBSD') | |
child.expect('ftp>') | |
child.sendline('get README.TXT') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Parsing apache logs to a CSV using python | |
import csv | |
OutputCsv = open("/some/path/output.csv",'wb') | |
Writer = csv.writer(OutputCsv) | |
header = ['User Address', 'Date/Time', 'Action', 'Requested URL', 'Return Code', 'Size'] | |
Writer.writerow(header) | |
f = open('/some/path/http_logs.log', 'r') | |
for line in f: | |
line = line.split() | |
line = line[0:4] + line[5:7] |