view export_local_file.sh @ 7:e5a905df7e0b draft

Uploaded
author david-hoover
date Thu, 04 Oct 2012 14:48:02 -0400
parents c772c8912663
children
line wrap: on
line source

###
### The shell script: export_local_file.sh
###
### The script basically copies a Galaxy dataset (param 1, dataset_NNNNN.dat) 
### to the destination file (param 2, {/data,/home}/filename
###
#!/bin/sh

INPUT="$1"
DEST="$2"
EMAIL="$3"
OUTPUT="$4"
USER=`echo $EMAIL | sed -e 's#@.*##'`

if [ -z "$DEST" ]; then
	echo "Usage: $0 [INPUT] [DEST]" >&2
	exit 1
fi

# Filter any unwanted directories

if [[ `echo $DEST | grep -c ^/data/` -lt 1 ]] && [[ `echo $DEST | grep -c ^/home/` -lt 1 ]] ; then
  echo "Error: \"$DEST\" is not allowed" >&2
  exit 1
fi

# Do the deed

cpy $INPUT $DEST "$USER"
dataset=`basename $INPUT`
if [ $? != 0  ]; then
  echo "Error: $USER failed to copy dataset $dataset to \"$DEST\"" >&2 
  exit 1
fi

echo "Dataset $dataset successfully exported to \"$DEST\"" >> $OUTPUT

exit 0

###
###
###