#!/bin/bash #+ # NAME: # qget # PURPOSE: # Copy files to user directory in SMEI tree on ips.ucsd.edu # CALLING SEQUENCE: # qget source_dir source_file_1 [source_file_2 source_file_3 ... ] # INPUTS: # source_dir source directory # Relative directory spec. # The files are copied to a directory on ips: # $SMEI/user/$USER/destination_dir # where environment variable $USER is the username of # the account from which the script is executed. # source_file_i file(s) to be copied with optional wildcard # EXAMPLE: # If logged in on any machine on account with user name phick # qget pro/drivers laserjet.pro # copies file laserjet.pro from ips into directory # $SMEI/user/phick/pro/drivers. # RESTRICTIONS: # The directory $SMEI/user/$USER must exist on ips. # The assumption is that every user with an entry in $SMEI/user # has an account with a username identical to the directory name. # PROCEDURE: # If logged in on ips the 'cp' command is used. # If logged in on any of the other boxes, 'scp2' is used (and user # will be prompted for a password). # MODIFICATION HISTORY: # JUL-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) #- # Do not execute this on the soft or root accounts (the directory # $SMEI/user/$USER does not exist). if [ "$USER" == "soft" -o "$USER" == "root" ]; then echo Script cannot be run from "soft" or "root" accounts exit 1 fi # At least one command line argument must be specified (source files) if [ -z "$1" ]; then echo No source files specified exit 1 fi if [ "$HOSTNAME" == "ips.ucsd.edu" ]; then on_ips=1 else on_ips=0 fi if [ $on_ips == 1 ]; then user_dir=$SMEI/user/$USER/ else user_dir=$SMEI_MASTER/user/$USER/ fi # Loop through all the command line arguments. # The first one is is the source directory on ips. All preceding ones are # assumed to be file names in the source directories to be copied to the local # machine source="$user_dir$1/" files="" shift while [ -n "$1" ]; do echo $source$1 files="$files $source$1" shift done if [ $on_ips == 1 ]; then cp $files ./ else scp2 $files ./ fi exit 0