#!/bin/bash
#
# Debugging log file, change from /dev/null if you like.
#
#logfile=/tmp/smb-print.log
logfile=/dev/null

if test -L $logfile ; then
	echo "$0: $logfile should not be a symbolic link." 1>&2
	exit 2
fi

#
# Protect the password
#
umask 0066
if ( >> $logfile ) 2> /dev/null ; then
	#
	# Some debugging help,
	# change the >> to > if you want to same space.
	#
	exec >> $logfile      2>&1
else
	rm -f   ${logfile}.$$
	exec  > ${logfile}.$$ 2>&1
fi

#
# Print out the used command line
#
echo smbclient $@

#
# Supplement and pass standard input to smbclient
#
(
  # NOTE You may wish to add the line `echo translate'
  # if you want automatic CR/LF translation when printing.
  #     echo translate
	echo "print -"
	cat
) | smbclient ${1+"$@"}
