Skip to content

Instantly share code, notes, and snippets.

@first-developer
Last active August 29, 2015 14:05
Show Gist options
  • Save first-developer/416304d3df5aa0311449 to your computer and use it in GitHub Desktop.
Save first-developer/416304d3df5aa0311449 to your computer and use it in GitHub Desktop.
Exemple de shell script
#!/bin/bash
# --------------------------------------------------------------------------
# Script : find_local_static_links_on
# Created on : 12/04/14
# Project : RUN_TEAM
# Author : <author>
# Company : COMPANY
# Copyright : (c) 2014 - COMPANY S.A.S
# --------------------------------------------------------------------------
BLUE="\033[1;36m"
RESET_COLOR="\033[0m"
RED="\033[0;31m"
function usage(){
echo "
find_local_static_links_on : Show the list of remote files that still contains local static resource's links
Usage:
find_local_static_links_on [OPTIONS]
find_local_static_links_on -h|--help
Options:
-h|--help Show command help
-s <server> The server on which we want to list file that contents
local link to static resources.
"
}
function echo_s(){
echo -e "\n\n$BLUE--------------------------"
echo -e "Server : $1"
echo -e "--------------------------$RESET_COLOR"
}
function err() {
echo -e "\n${RED}[Error]$RESET_COLOR $*\n"
}
function find_local_static_links_on() {
s=$1
if [ -z $s ]; then
err "No server given. Use : \n\t-s <server> where <server> is the server on which we want to lookup static resource's links left."
fi;
echo_s $s
ssh ${s} "<CMD>"
}
if test $# -eq 0
then
usage
fi
while test $# -gt 0; do
case "$1" in
-h|--help)
usage
exit 0
;;
-s)
shift
SERVER=$1
shift
;;
*)
err "Option [$1] is not supported!"
usage
exit 1
;;
esac
done
if [ -z $SERVER ]; then
err "Missing argument <server> via option [-s]."
exit 1
else
find_local_static_links_on $SERVER
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment