Using AWS EC2 CLI - part 2

Published on Author admin

Using AWS EC2 CLI - part 2 Script for checking VMs status: https://github.com/openterprise/scripts/blob/master/aws-status.sh Example user data file script: https://github.com/openterprise/scripts/blob/master/aws-user-data.sh #create VM centos aws ec2 run-instances --image-id ami-18f8df7d --security-group-ids sg-ID --subnet-id subnet-ID --count 1 --instance-type t2.micro --key-name KEY-NAME --user-data file://aws-user-data.sh --block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=10,DeleteOnTermination=false}' --query 'Instances[0].InstanceId' #stop ALL instances (only those are running) aws ec2 stop-instances --instance-ids `aws… Continue reading Using AWS EC2 CLI - part 2

Bash swap function for swapping two files

Published on Author admin

Put following function definition code into ~/.bashrc file: function swap()         {     local TEMPFILENAME=tempfile.$$     mv "$1" $TEMPFILENAME && mv "$2" "$1" && mv $TEMPFILENAME $2 } Usage: swap FILE1 FILE2 This solution was originally found at: https://stackoverflow.com/questions/1115904/shortest-way-to-swap-two-files-in-bash/1115909#1115909

SSH connection inside while Bash loop

Published on Author admin

When using SSH connection inside while Bash loop, there is need to redirect SSH input to /dev/null, as SSH reads standard input by default: #!/bin/bash while read IP; do echo $IP; ssh root@$IP -C hostname < /dev/null; echo "" done < ip.txt Contnet of ip.txt file: 192.168.0.10 192.168.0.11 192.168.0.12

Python - example of proof-of-work mechanism in Bitcoin

Published on Author admin

Simple Python script presenting proof-of-work mechanism in Bitcon. https://github.com/openterprise/scripts/blob/master/blockchain-proof-of-work-example.py Script output: Nonce: 118 Hash(Nonce): 00cc2e9f7a37a0fdf0fc99d8fa0c7ce8f7cae298854c8581886c66dc1776fd00 Seconds: 0.0002713203430175781 Nonce: 145875 Hash(Nonce): 000003b0c79c3faff75237486788d0f6cc53c8d0f2a285fefcd6431cff8bbe35 Seconds: 0.34033846855163574 Nonce: 12007876 Hash(Nonce): 000000f022498f1e990efb8ec4d730c5ce4248097489beace7ec0accb1ae656c Seconds: 29.438159942626953 Nonce: 11042531297 Hash(Nonce): 00000000cb5b5928f89ed2a91fda881ffa4e5597fc07d4da22d1259771272cb3 Seconds: 27913.442200899124