Visit The New, Modern Unix Linux Community


Script issue - Prints pages with jibberish...

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Script issue - Prints pages with jibberish...
# 1  
Script issue - Prints pages with jibberish...

Hi all,

I have a script from a programmer, for which I need to analyze a problem.

The script gathers audit info and prints out the results. Two different departments use it, on two different printers. In the script department the there are no issues. In the other department the same script produces "problem" pages among the normal pages. They are either blank, or full of random collection of characters.

I need to put some kind of echo statements around the print functions and redirect it to a sort of error_show.txt file, so that we can see what is happening. We presume it is due to the usage of different printers.

If we can visualize the errors we can see if it is a problem with printer type or settings or whatnot.

This is the code

Code:
#!/usr/bin/sh
 export PATH=/usr/bin:${PATH}
 PRINTER="system"  
 ERRFILE=$(mktemp -c)
 while getopts d: optchar; do
 case $optchar in
 d)
 PRINTER=$OPTARG;;
 esac
 done
 if [ -z "${PRINT_SERVER_HOME}" ]; then
 [[ -f `cat /etc/PRINT_SERVER_HOME`/custom/etc/setup_env.sh ]] && . `cat /etc/PRINT_SERVER_HOME`/custom/etc/setup_env.sh
 fi
 if [ -z "${PRINT_SERVER_HOME}" ]; then
 echo "Unable to setup PRINT_SERVER environment"
 echo "Exitting..."
 exit 1
 fi
 cd /var/spool/edi/ebill/audits
 # We would like to print Audit files for AVAL
 # if file aval.lst existed then delete it
 if [ -e aval.lst ]; then
 rm aval.lst
 fi
 # if avalaudt3.* exists then execute ll command below
 if [ -e avalaudt3.* ]; then
 ll avalaudt3.*>>aval.lst
 fi
 AVALFILELIST=$(gfind . -type f -name "avalaudt3.???" | sort -t'.' +2 )
 AVALNEWFILELIST=""
 for AVALFILE in ${AVALFILELIST}; do
 if [ -s ${AVALFILE} ]; then
 AVALNEWFILELIST="${AVALNEWFILELIST} $(pwd)/${AVALFILE##./}"
 fi
 done
 # if file aval.lst exists and not empty
 if [ -s aval.lst ]; then
 ${PRINT_SERVER_HOME}/bin/pdpr -d${PRINTER} -x"-start-sheet none" ${AVALNEWFILELIST} >${ERRFILE} 2>&1
 fi
 if [ $? -ne 0 ]; then
 echo "ERROR: pdpr command failed for file aval.lst" >&2
 cat ${ERRFILE} >&2
 fi
 rm -f ${ERRFILE} 2>/dev/null

I have highlighted the print function. Any help would be appreciated. The programmer inherited the script an doesn't want to delve too deeply into it.

I, however, would like to figure out what is happening and not waste the paper. However, this kind of script is way above my head, as of right now.

Last edited by zixzix01; 09-15-2011 at 03:51 PM..
# 2  
The problem may just be the avalaudt3.* input files generated there. It is a bit odd to juggle two lists, one from ll and one from gfind !
This User Gave Thanks to DGPickett For This Post:
# 3  
Thanks,

I had the script fixed up a bit...

However getting an error when I'm trying to echo the print function to a file.

Here is the code:

Code:
#!/usr/bin/sh
 #put /usr/bin in the path first. This is for security
 export PATH=/usr/bin:${PATH}
 #Get the Output Server environment variables in
 if [ -z "${Print_Server_HOME}" ]; then
 [[ -f `cat /etc/Print_Server_HOME`/custom/etc/setup_env.sh ]] && . `cat /etc/Print_Server_HOME`/custom/etc/setup_env.sh
 fi
 if [ -z "${Print_Server_HOME}" ]; then
 echo "Unable to setup Print_Server environment"
 echo "Exitting..."
 exit 1
 fi
 #Script Variables
 PRINTER="system"  
 ERRFILE=$(mktemp -c)
 DIR="/var/spool/edi/ebill/audits"
 #parse command line arguments
 while getopts d: optchar; do
 case $optchar in
 d)
 PRINTER=${OPTARG};;
 esac
 done
 ###############################################################
 # Main Program
 ###############################################################
 cd ${DIR}
 #if [ $? -ne 0 -o $(pwd) != ${DIR} ]; then do
 if [ $? -ne 0 -o $(pwd) != ${DIR} ]; then
 exit 1
 fi
 # We would like to print Audit files for AVAL
 # if file aval.lst existed then delete it
 [[ -f aval.lst ]] && rm aval.lst
 #if [ -f aval.lst ]; then
 # rm aval.lst
 #fi
 # if avalaudt3.* exists then execute ll command below
 #if [ -e avalaudt3.* ]; then
 # ll avalaudt3.*>>aval.lst
 #fi
 #AVALFILELIST=$(gfind . -maxdepth 1 -type f -name "avalaudt3.???" | sort -t'.' +2 )
 #AVALNEWFILELIST=""
 #for AVALFILE in $(cat ${AVALFILELIST}); do
 #for AVALFILE in $(gfind . -maxdepth 1 -type f -name "avalaudt3.???" -size +0 | sort -t'.' +2); do
 # #if [ -s ${AVALFILE} ]; then
 # AVALNEWFILELIST="${AVALNEWFILELIST} $(pwd)/${AVALFILE##./}"
 # #fi
 #done
 AVALNEWFILELIST=$(gfind . -maxdepth 1 -type f -name "avalaudt3.???" -size +0 | sort -t'.' +2)
 echo ${AVALNEWFILELIST} | xargs -i ll -d "{}" >aval.lst 2>&1
 # if file aval.lst exists and not empty
 if [ -s aval.lst ]; then
 echo "AVALNEWFILELIST: ${AVALNEWFILELIST}" >> {"/home/user1/bin/outfile.out"} 2>&1
 #pdpr -d${PRINTER} -x"-start-sheet none" ${AVALNEWFILELIST} >${ERRFILE} 2>&1
 #${Print_Server_HOME}/bin/pdpr -d${PRINTER} -x"-start-sheet none" ${AVALNEWFILELIST} >${ERRFILE} 2>&1
 RET=$?
 fi
 ###############################################################
 ###############################################################
 ###############################################################
 ###############################################################
 ###############################################################
 #Testing
 ###############################################################
 ###############################################################
 ###############################################################
 ###############################################################
 ###############################################################
 exit 0
 ###############################################################
 if [ ${RET} -ne 0 ]; then
 echo "ERROR: pdpr command failed for file aval.lst" >&2
 cat ${ERRFILE} >&2
 fi
 [[ -f ${ERRFILE} ]] && rm -f ${ERRFILE} 2>/dev/null

Getting a:

Quote:

./test_audit.sh[67]: {/home/user1/bin/outfile.out}: Cannot create the specified file.
I must have put something wrong in the redirect section of the echo statement.

Last edited by zixzix01; 09-16-2011 at 03:56 PM..
# 4  
Why are you using
Code:
{"/home/user1/bin/outfile.out"}

Just put filename alone without braces and ".
This User Gave Thanks to tene For This Post:
# 5  
Thank you. I figured that out.
# 6  
Do you have write permission for the output?
Quote:
./test_audit.sh[67]: {/home/user1/bin/outfile.out}: Cannot create the specified file.
This User Gave Thanks to vbe For This Post:
# 7  
Yes, I'm using root so no problem there. I think the problem is in the different printers. Something is going on there.

I was able to get the echo statement and output and it still prints out weird pages.

Getting a fresh set of files tomorrow. Will see what happens...

Printers are called through Output Server...

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #701
Difficulty: Easy
MySQL NOT LIKE is a sardonic DB operator used to exclude those rows which are not liked by Oracle Corporation executives.
True or False?

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Man Pages - Removed Table Tags and Fixed Scrollbar Issue

OK. I fixed the horizonal scroll bar issues in the man pages pre format output for the man pages by removing all table tags and converting to divs: https://www.unix.com/members/1-albums220-picture876.png I still have some work to do on reformatting the deep search redirects and the... (0 Replies)
Discussion started by: Neo
0 Replies

2. Web Development

Php script prints values but not seen in browser

greetings, i'm a php and html novice and i figured i'd learn by diving in. i've written a php script that i've placed in the /var/www/html directory. it's supposed to give some relative info about the system when you point a browser at it. if i run the script using "php -q index.php" all the... (3 Replies)
Discussion started by: crimso
3 Replies

3. Shell Programming and Scripting

Script which telnets to a device, runs commands and prints output to a file

I am connecting to a device using telnet, I want my script to perform certain commands : ie- show device , show inventory..etc and write the output it sees from the terminal to a file. this is what I have got : #!/usr/bin/expect -- set running 1 spawn telnet <ip address> expect ... (1 Reply)
Discussion started by: samantha123
1 Replies

4. Shell Programming and Scripting

Script to compare 2 files and prints difference as output sidebyside

Hi All, Am trying script to compare 2 files and print the difference found from old file to new file on line by line basis on side by side display. Basically line by line comparision and files may contain blank line as well I know we have compare/diff commands but i don't how to make... (10 Replies)
Discussion started by: Optimus81
10 Replies

5. UNIX for Dummies Questions & Answers

Client web pages very slow to load. Squid issue?

Hi. I have netBSD box acting as gateway, ftp, mail & web server, etc. It is now seven years old and has never missed a beat. The only problem is that the (Windows) boxes in my little network are now experiencing VERY slow web page loads. The other problem is that in the years since a Unix... (0 Replies)
Discussion started by: torontobob
0 Replies

6. Shell Programming and Scripting

Script that prints 2 messages to a screen session

Im trying to make a script that prints 2 messages to a screen session, one after the other. screen -x session44 -X stuff "`printf "Test 1\r"`" This works fine, but adding a second lien with a different message yields no results. Changed Subject: Please Follow Forum Rules Regarding... (1 Reply)
Discussion started by: kylecn
1 Replies

7. Shell Programming and Scripting

echo prints nothing-shell script

could anyone tell me why when i execute the following script, echo returns blank set k = 1 echo $k (9 Replies)
Discussion started by: saman_glorious
9 Replies

8. UNIX and Linux Applications

netcat prints blank pages

Please direct me to the right forum tree if i am in the wrong section for this. i have netcat on a unix machine and there is no man nc or man netcat available. my command i am using is: cat $FILE1 | netcat -h $PRINTER -p 9100 (-h -p -d are the only flags available in this version of... (3 Replies)
Discussion started by: dunpealslyr
3 Replies

9. Solaris

man pages issue

hi all i have installed veritas storage foundation 5.1 in my sun blade 150 which running with sun solaris 5.10. Veritas commands manual pages are located in /opt/VRTS/man/man1m directory. But if i give "man vxassist" It says "no manual entry for vxassist". How to resolve this? (2 Replies)
Discussion started by: kingston
2 Replies

10. UNIX for Dummies Questions & Answers

Printer prints blank pages

Hello Everyone :) , I have this printer installed on the network which is an HP 1160. When sending a print job to the printer from SCO Unix 7.1 it prints one line of text and the rest of it comes up with blank pages. I have tried deleting the printer and recreating it; but I am getting... (6 Replies)
Discussion started by: George26
6 Replies

Featured Tech Videos