Skip to content

Instantly share code, notes, and snippets.

View halleshubham's full-sized avatar

SHACK halleshubham

  • Scientific Games
  • Pune
View GitHub Profile
@halleshubham
halleshubham / BASH_DeployExecuteScript_On_RemoteLinux.sh
Last active September 3, 2018 11:53
BASH: Deploy and execute script on remote Linux node
#!/bin/bash
PASSWORD=<PASSWORD>
node=<IP>
# Copy to remote node
echo y | pscp -pw "${PASSWORD}" /path/to/Script.sh <user>@"$node":/tmp/Script.sh
# Move to required / accessible directory
echo y | plink -ssh -pw "${PASSWORD}" -t <user>@"$node" "sudo cp /tmp/Script.sh /required/path/"
# Convert to Linux BASH (if file edited in Windows)
@halleshubham
halleshubham / BASH_ParsePropertiesFile.sh
Last active September 3, 2018 11:52
BASH: Parse .properties file into two saperate arrays.
#!/bin/bash
file=<filename.format>
declare -A valueArray
declare -a keyArray
while IFS='=' read -r key value
do
key=($(echo $key | tr '.' '_'))
@halleshubham
halleshubham / BASH_CheckSubString.sh
Last active September 3, 2018 11:52
BASH script to Check for sub string
#!/bin/bash
if [[ "$string" == *"$substring"* ]]; then
# TO DO
fi
@halleshubham
halleshubham / BASH_ParseHostNPort.sh
Created September 3, 2018 11:52
BASH: from lines of output of BASH command, parse host and port number.
#!/bin/bash
while IFS= read -r line;
do
URL=$(echo $line | grep / | cut -d/ -f3)
HOST=$(echo $URL | grep : | cut -d: -f1)
PORT=$(echo $URL | grep : | cut -d: -f2)
# TO DO
done < <( cat <file.format> | grep <substring> )