cancel
Showing results for 
Search instead for 
Did you mean: 

Bourne shell script

 
Highlighted
Advisor

Bourne shell script

Do you know how to slove this script:

write a Bourne shell that will allow a user to specify a number of files to be printed and which email the user with the results of the command. The script should email the user a list of the files that were sent to the printer as well as a list of the files that could not be sent to the printer.

i tried to do this but wont work...please help...
hey
12 REPLIES 12
Highlighted
Honored Contributor

Re: Bourne shell script

Sophia,

It would be good if you could post out your script so that we may debug it.

- ramd.
HPE Software Rocks!
Highlighted
Advisor

Re: Bourne shell script

if [ $# -eq 0 ]
then
echo "Usage:./printfile directory_name" 1>&2
exit 1
else
cd $1 ls ; (ls | wc -w)
echo "Number of files to be printed: " 1>&2
read fileNo
while [ !$fileNo ]
do
lpr -P[printer]
lpr -m logname
done
fi



i dunno wat to do...quite embarassing to show my script actually
hey
Highlighted
Honored Contributor

Re: Bourne shell script

hi sophia,
is this some kind of a home work u r looking for? :-(



do u have a script already built. if yes, pls post it. we can try to fix it.

hth
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Highlighted
Honored Contributor

Re: Bourne shell script

Hi sophia,

try this for checking if the lpr command returned successfully -

res=`lpr -P $docname`
if [[ $res -ne 0 ]]; then
echo "error occured while printing $docname"
else
echo "successfully printed $docname"
fi

HTH.

- ramd.
HPE Software Rocks!
Highlighted
Honored Contributor

Re: Bourne shell script

Hi sophia,

try this for checking if the lpr command returned successfully -

res=`lpr -P $docname`
if [[ $res -ne 0 ]]; then
echo "error occured while printing $docname"
else
echo "successfully printed $docname"
fi

HTH.

- ramd.
HPE Software Rocks!
Highlighted
Honored Contributor

Re: Bourne shell script

Hi sophia,

try this for checking if the lpr command returned successfully -

res=`lpr -P $docname`
if [[ $res -ne 0 ]]; then
echo "error occured while printing $docname"
else
echo "successfully printed $docname"
fi

HTH.

- ramd.
HPE Software Rocks!
Highlighted
Honored Contributor

Re: Bourne shell script

Oops! That echoed!!!

- ramd.
HPE Software Rocks!
Highlighted
Advisor

Re: Bourne shell script

it says [: -ne:unary operator expected
hey
Highlighted
Honored Contributor

Re: Bourne shell script

hi,

Try the attached script.

call as ./sh.sh

ensure that execute permissions are available. if not, run
chmod +x sh.sh

- ramd.
HPE Software Rocks!