#!/bin/csh -f # push_protected_file_to_server # ----------------------------------------------------------------------------- # Shell script to push a local file to a protected location on a server # Run locally by Fred to update a remote config file on a server. # ----------------------------------------------------------------------------- # Usage: See Usage section below or run with -h or --help option to see usage. # Assumptions: # - Assumes sudo rights on the remote server # - Assumes diffcprm command is on the PATH at the remote server # - Assumes the remote file already exists. Overwrites, but does not create. # Effects: # - Pushes the file to the home directory on the remote server, and then # moves it to the specified location using sudo rights. # Notes: # Implementation Notes: # Portability Issues: # - Not very portable. Performs a specific useful task in Fred's typical # environment. # Revision History: # $Log$ # ----------------------------------------------------------------------------- if ($#argv < 3 || "$1" == "-h" || "$1" == "--help") then echo "Usage: $0:t host local_file_name remote_file_name" echo "host = Name or IP of server." echo " Example: 174.129.10.250 or bristle.com" echo "local_file_name = Name of local file to push" echo " Example: hosts or ./etc/hosts" echo "remote_file_name = Name of remote file to overwrite" echo " Example: /etc/hosts" exit 1 endif set host=$1 set local_file_name=$2 set remote_file_name=$3 set temp_file_name="$0:t.tmp" set echo scp ${local_file_name} ${host}:${temp_file_name} ssh -t ${host} diffcprm ${temp_file_name} ${remote_file_name}