#!/bin/bash #+ # NAME: # qput # PURPOSE: # Copy files to user directory in SMEI tree on ips.ucsd.edu # CALLING SEQUENCE: # qput source_file_1 [source_file_2 source_file_3 ... ] [destination_dir] # INPUTS: # source_file_i file(s) to be copied with optional wildcard # OPTIONAL INPUTS: # destination_dir destination directory; default: null string # This is a 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. # EXAMPLE: # If logged in on any machine on account with user name phick # qput laserjet.pro pro/drivers # copies file laserjet.pro to ips in directory # $SMEI/user/phick/pro/drivers. # SEE ALSO: # qget # 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 # Loop through all the command line arguments. # The last one is taken as the destination. All preceding ones are # assumed to be source files. source="$1" destination="" shift while [ -n "$1" -a -z "$destination" ]; do if [ -f "$1" ]; then source="$source $1" else destination="$1" fi shift done 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 destination=$user_dir$destination echo Source: $source echo Destination: $destination if [ $on_ips == 1 ]; then cp $source $destination else scp2 $source $destination fi exit 0