Submitting text files with a shell script

You can email text files as they are, ripped at destination, or you can create a shell script (named sendtxtfile for this example) to submit ASCII text files as e-mail.

Create a file that contains the pdpr command and all its attributes. Create a shell script and put it in a directory on the system where you have installed the pdpr command.

The file should look similar to this:

		# Sample Shell
		# Script for InfoPrint Manager Email Text
      # Uses a script to submit:
      # sendtxtemail $1 $2
      # $1 is required as the name of the file to send.
      # $2 is optional as the recipient of the email.
      #
      # This script takes an ASCII file as input and creates
      #PostScript output that is submitted with the pdpr command
      # as email.
      #! /usr/bin/ksh
      if [[ -a $1 && -n $1] ]
      then 
      if [ $2 ]
      then
      WHOTO=$2
      else
      WHOTO="johndoe@us.name.com"
      fi
      # Make temporary PostScript file
      enscript -p /tmp/$$email.txt $1
      /usr/lpp/pd/bin/pdpr -p email1-ld \
      -r brief \
      -x email-to-address=$WHOTO \
      -x email-from-address=root@serv.us.name.com \
      -x "subject-text='Your requested Email file'" \
      -x document-type=printable /tmp/$$email.txt \
      -x document-type=email-body /email_script/body.txt \
      -x document-type=email-signature /email_script/sig.txt 
      # Delete temporary PostScript file
      rm /tmp/$$email.txt
      else
      echo " sendtxtfile: could not locate file [$1]"
      fi

On the command line, this shell script uses this syntax:

sendtxtfile outputfilename [destination]
where outputfilename specifies the file that you are sending (email.txt) and destination is the e-mail address (johndoe) to which you are sending the file.

This script sends an e-mail to either the destination value that you specify as the second argument on the command line, or to 'johndoe' Internet ID, if you use the default. The script uses a logical destination (printer) named email-ld on your InfoPrint server. This file uses the enscript command to convert the text file to PostScript, stores that PostScript file in the /tmp directory on the submitting system, and then deletes that file after the pdpr command has submitted the PostScript file to the InfoPrint server.

The convention us.name.com indicates a typical Internet address for a business.