1847253 Members
4397 Online
110263 Solutions
New Discussion

Script question

 
SOLVED
Go to solution
Jeffrey F. Goldsmith
Super Advisor

Script question

My manager wanted me to modify our 'prt' script so that information from all the reports that are printed goes to a 'record' file. That seems to be working fine but sometimes we get some reports that have headers that are much longer and have caused us problems.
I tried to make a change to the script to keep any file headers of a certian length are ignored. With that change none of the header information is going into the 'record' file. Any ideas as to what I am doing wrong?
I am attaching the script and I also highlighted the part that I am having problems with.
Thanks for the help.
3 REPLIES 3
Jeroen Peereboom
Honored Contributor
Solution

Re: Script question

Hi Jeff,

you commented out 3 lines (around the rm -rf /tmpspool/.$$)? Is that the change you made?

I see 2 other things:
1)
if [ "$12" = '' ]
then
echo `date +%D-%X` $1 $2 $3 $4 $5 $6 $7 $8 >> /tmpspool/record
fi

$12? Is there a $12 in the call to your script? Do a short test by creating a script that prints $12 and ${12}!
$12 equals $1 followed by the digit 2 I'm afraid. So indeed it's never equal to '' and nothing gets logged.

2) There is a chmod command all alone on a line, without arguments.

In ksh you can also define a variable with a fixed length (typeset -L40: left justified, leading blanks removed, 40 chars, padded on the right with blanks if necessary). Maybe that's of any help.

JP
Francisco J. Soler
Honored Contributor

Re: Script question

Hi, where are the part you have trouble?, i can't find it.

Frank.
Linux?. Yes, of course.
Jeffrey F. Goldsmith
Super Advisor

Re: Script question

The part that I was having problems with was the following:

if [ "$12" = '' ]
then
echo `date +%D-%X` $1 $2 $3 $4 $5 $6 $7 $8 >> /tmpspool/record
fi

With your help I was able to figure out what needed to be fixed. This is what it now looks like and it seems to be working fine:

if [ "${12}" = '' ]
then
echo `date +%D-%X` $1 $2 $3 $4 $5 $6 $7 $8 >> /tmpspool/record
fi

I had to put brakets around the 12. Thanks for the help.