Saturday, December 31, 2016

utility

#!/bin/bash
# Search script
#./search <serverIP> <username> <password> <path> <text>
if [[ -z "${S_SERVER_IP}" ]]; then
  echo "S_SERVER_IP is not exported, please set S_SERVER_IP using export command"
  exit 1
fi
if [[ -z "${S_USER_NAME}" ]]; then
  echo "S_USER_NAME is not exported, please set S_USER_NAME using export command"
  exit 1
fi
if [[ -z "${S_PASSWORD}" ]]; then
  echo "S_PASSWORD is not exported, please set S_PASSWORD using export command"
  exit 1
fi
if [[ -z "${S_PATH}" ]]; then
  echo "S_PATH is not exported, please set S_PATH using export command"
  exit 1
fi
if [[ -z "${S_SEARCH}" ]]; then
  echo "S_SEARCH is not exported, please set S_SEARCH using export command"
  exit 1
fi
echo "Server: $S_SERVER_IP"
echo "USERNAME: $S_USER_NAME"
echo "PASSWORD: $S_PASSWORD"
echo "S_PATH: $S_PATH"
echo "S_SEARCH: $S_SEARCH"
#echo "echo '$S_PASSWORD' | sudo -S grep -rnw $S_PATH -e $S_SEACRH"
ssh $S_USER_NAME@$S_SERVER_IP "echo '$S_PASSWORD' | sudo -S grep -rnw $S_PATH -e $S_SEARCH" > output.txt


------------------------------------------------------------------------



#!/bin/bash
# Search script
#./search <serverIP> <username> <password> <path> <text>
if [ "$#" -ne 5 ]; then
  echo "Usage: $0 SERVER_IP USERNAME DIRECTORY TEXT" >&2
  exit 1
fi
ssh $2@$1 "echo '$3' | sudo -S grep -rnw $4 -e $5" > output.txt

Hyderabad Trip - Best Places to visit

 Best Places to Visit  in Hyderabad 1.        1. Golconda Fort Maps Link :   https://www.google.com/maps/dir/Aparna+Serene+Park,+Masj...