Skip to content

Instantly share code, notes, and snippets.

@dhrp
Created March 29, 2017 05:00
Show Gist options
  • Save dhrp/e81a630ae588a28ac13b236698c708d5 to your computer and use it in GitHub Desktop.
Save dhrp/e81a630ae588a28ac13b236698c708d5 to your computer and use it in GitHub Desktop.
Entrypoint example of batch Dockerfile
#!/bin/sh
# Usage: $0 <inputfile.ext
#
# Program takes input from standard in, saves it
# and then lets PSSPred run with that inputfile
TMP_FILE=/tmp/input.txt
# Clean up the temp file
rm -f $TMP_FILE
# Read the input (which could be multiline)
# and write it to the temp file
while read line
do
echo "$line" >> $TMP_FILE
done < "${1:-/dev/stdin}"
echo "processing: "
cat $TMP_FILE
# Read the first line of the file, this will be used for logging
read -r firstline<$TMP_FILE
# Do something <INJECT YOUR SCRIPT HERE>
cat $TMP_FILE >> /mnt/output/result.txt
# Append date and first line to logfile
echo "`date` $firstline" >> /mnt/output/log.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment