#!/bin/bash
if [ "$1" = "" -o "$2" = "" -o "$3" = "" ]; then
 echo "usage: subput HLQ src.file 'DSN'"
 exit 1
fi

if ! test -f $2 ; then
  echo file $2 does not exist
  exit 1
fi

cat <<EOF | a2e -p - >/tmp/copy$PPID.jcl
//$1PT JOB (PUT),'PUT',MSGCLASS=A,MSGLEVEL=(1,1)
//CC       EXEC PGM=IEBGENER,REGION=128K
//SYSPRINT DD   SYSOUT=*
//SYSUT2   DD   DSN=$3,DISP=SHR
//SYSIN    DD   DUMMY
//SYSUT1   DD   DATA,DLM='><'
EOF

cat $2 | a2e -p - >>/tmp/copy$PPID.jcl

cat <<EOF | a2e -p - >>/tmp/copy$PPID.jcl
><
EOF

sub /tmp/copy$PPID.jcl
rm -f /tmp/copy$PPID.jcl
