Question

Explain everything that is happening on line 125 of the script, where the roff2pdf() function is called. (Hint: sort out the function arguments and input/output redirection.)

line 125: roff2pdf "$OUTPUT_TITLE" < $TMP_FILE_M > $OUTPUT_FILE

#1 /bin/sh # Verify that the command line arguments are suitable if [ -z $1 ] 11 [ $# -gt 2 ]; then echo Usage: $0 <page>--prologue-ul --center-title=\$1\ --medium-Letterdj --header---left-title: -footer--left-footer -i \ \ A2PS. CMDzif [ $MAN SECTION- 1; then # We dont know the man section, so use a simpler title. OUTPUT_TITLE $MAN WORD # File name wTMP FILE M-$(mktemp) man $MAN_ARGS> $TMP FILE_M 2>/dev/null RETVAL-$? if [ $RETVAL -ne e ]; then echo Error accessing man

#1 /bin/sh # Verify that the command line arguments are suitable if [ -z "$1" ] 11 [ $# -gt 2 ]; then echo "Usage: $0 []" exit 1 1 # util is avail # Check whether a utility is available on the system. # $1 return value upon failure $2 utility name util is avail () if [! -x $(which $2) ]; then echo "Error: utility $2 not found." 1>&2 exit $1 else return θ 1 # Check for the various utilities needed by this scrip util is avail 1 'gawk util is avail1 1 'man" util is avail1 1 'a2ps" util is avail1 1 'ps2pdfwr' util is avail1 1 'tr' util is avail1 1 'uname util is avail 1 'mktemp" # Query the operating system we're using. OS_TYPE $(uname -s) # roff2pdf # Convert a roff-formatted file to PDF using a2ps. roff2pdf() TMP FILE R-"$(mktemp)"
--prologue-ul --center-title=\"$1\" --medium-Letterdj --header-''--left-title: '' -footer-''-left-footer'' -i \ \ A2PS. CMDz "a2ps ${TMP-FILE-RI" -o case $OSTYPE in SunoS) # SunOS puts headers and footers in the man page output, so we need # to strip these out using awk. gawk-f SunOS-manfix. awk--| $A2PS. CMD 2〉/dev/null $A2PS CMD 2>/dev/nul1 esac RETVAL-$? if [ $RETVAL -ne e ]; then rm f $TMP_FILE_R return $RETVAL 1 ps2pdf STMP FILE R RETVAL-$? rm f $TMP_FILE_R return $RETVAL # man2pdf # Convert a man page to PDF format using rotf2pdf. man2pdf () MAN SECTION-"$1" shift MAN WORD"$"
if [ "$MAN SECTION"-" 1; then # We don't know the man section, so use a simpler title. OUTPUT_TITLE "$MAN WORD" # File name will not have any whitespace or newline characters OUTPUT FILE-"man-$ (echo $MAN WORD tr -d n' | tr '[:space:]]' '_').pdf" else # Include man section in the title. OUTPUT_TITLE "$MAN WORD ($MAN SECTION)" # File name will not have any whitespace or newline characters OUTPUT_FILE-"man-$(echo $MAN WORD-$MAN SECTION| tr -d n' | tr '[:space:]]' '_').pdf" fi case $OS_TYPE irn SunoS) if [ "$MAN_SECTION"-" 1; then MAN ARGS-"$MANWORD" else MAN ARGS-"-s SMAN SECTION SMAN WORD" fi Linux) if [ "$MAN_SECTION"-" 1; then MAN ARGS-"-t SMAN WORD" else MAN ARGS-"-t SMAN SECTION SMAN WORD" fi if [ "$MAN_SECTION"-" 1; then MAN ARGS-"$MANWORD" else MAN ARGS"$MAN SECTION $MAN WORD" fi esac
TMP FILE M-"$(mktemp)" man $MAN_ARGS> $TMP FILE_M 2>/dev/null RETVAL-$? if [ $RETVAL -ne e ]; then echo "Error accessing man pages ($RETVAL) " 1>&2 rm f $TMP_FILE_M return $RETVAL fi roff2pdf "SOUTPUT-TITLE" RETVAL-$? $TMP-FILE-M $OUTPUT-FILE 〈 〉 if [ $RETVAL -ne e ]; then echo "Error generating output ($RETVAL)" 1> &2 rm f $TMP_FILE_M rm f $OUTPUT_FILE return $RETVAL fi rm f $TMP_FILE_M SECTION-"$2" if [ -z "$SECTION" J; then SECTION= '-' fi man2pdf "$SECTION" "$1"
0 0
Add a comment Improve this question Transcribed image text
Answer #1

roff2pdf "$OUTPUT_TITLE" < $TMP_FILE_M > $OUPUT_FILE
1 2 3

roff2pdf is a fuction which is being called with OUTPUT_TITLE is variable which contains total variable with MAN_WORD=$* [but "$*" is one string]

mktemp is util_is_avail list which will pass to TMP_FILE_M that will pass to roff2pdf function and > $OUTPUT_FILE will create new file with whatever arguemnt is pass suppose "hello world" is passed then file name will be hello-world.pdf will be stored in OUTPUT_FILE variable and created finally output filename.

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
Explain everything that is happening on line 125 of the script, where the roff2pdf() function is called. (Hint: sort out the function arguments and input/output redirection.) line 125: roff2pdf "$...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT