Operating System - Linux
1827633 Members
3731 Online
109966 Solutions
New Discussion

Post Conversion script not working - copying part of log

 
Jenny A Case
New Member

Post Conversion script not working - copying part of log

We just converted from a NUMAQ to HP.

The following script worked fine to copy every line from the current date forward:

datevar=$(date +'%b %e');
morevar="more -s /'$datevar' /dms/log/dms.log";
echo "$morevar" > temp.sh;
chmod +x temp.sh;
temp.sh > dmslog.$(date +%b%d);
rm temp.sh;

Now on the HP it copies the entire log. If I pick it apart and run everything manually, it works up to the "temp.sh > dmslog.$(date +%b%d);" line. For some reason it seems the redirection to a file causes it to choke, because if I just run the 'temp.sh' it outputs to the screen fine. Am I missing some HP scripting quirk?
5 REPLIES 5
Christian Tremblay
Trusted Contributor

Re: Post Conversion script not working - copying part of log

Try temp.sh 2>&1 > dmslog.$(date +%b%d);
James R. Ferguson
Acclaimed Contributor

Re: Post Conversion script not working - copying part of log

Hi Jenny:

Your script essentially executes 'more -s' against a file. In HP-UX, the '-s' switch of 'more' squeezes multiple blank lines into one on output. It doesn't filter anything else. Hence, your output is going to be the whole input file, less multiple blank lines as noted.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Post Conversion script not working - copying part of log

Hi (again) Jenny:

OK, I think I see what you want:

In HP-UX you can use 'more +/pattern' to start listing a file two lines above the regular expression 'pattern':

# more +/$datevar filename

Regards!

...JRF...
Jenny A Case
New Member

Re: Post Conversion script not working - copying part of log

I don't know why it didn't show up in my original message but I do have the '+' in the morevar definition:

morevar="more -s +/'$datevar' /dms/log/dms.log";

I tried the suggestion by Christine and it didn't work.

Put in an echo to see how if the date is populated okay and it seems to look fine:

more -s +/'May 31' /dms/log/dms.log

It works from the command line but the script doesn't like it. A real head scratcher...
Jenny A Case
New Member

Re: Post Conversion script not working - copying part of log

Sorry that should have been Christian. Thanks for the suggestion anyway. I'll play around with it to see what happens.