Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep fails to find ~, but finds "~", why? 2

Status
Not open for further replies.

TimRobDFW

MIS
Jan 25, 2002
13
US
SCO OpenServer 5.0.6

We have been running a script within a printer interface for faxing for since last May.

Here's the original line from the script:
grep -v ~ $FILES >> /tmp/$FILE.bat

This line strips out all the lines containing tilde, ~.

After deleting and adding another printer interface using the /usr/lib/hpnp/hpnpcfg utility, this script stopped working. Of course, running hpnpcfg is very common and may not have had anything to do with causing this problem.

The original script required modification to work. Here's two versions of the modified line that work:
grep -v "~" $FILES >> /tmp/$FILE.bat
or
grep -v \~ $FILES >> /tmp/$FILE.bat

Any ideas what could cause grep to stop recognizing tilde without the quotes?
 
I left out one other piece of information:

Last May we were running on SCO OpenServer 5.0.5. This January, we upgraded to 5.0.6.

On a test server running 5.0.5. I confirmed that grep finds the tilde without the quotes, but on our 5.0.6 server grep does not find the tilde without the quotes.

However, we did not have any trouble with this script until Feb 28th.
 
Can you spell "POSIX"? 5.0.6 more closely adheres to POSIX standards - I would suspect that's the reason.

Pat Welch, UBB Computer Services
Caldera Authorized Partner
Unix/Linux/Windows/Hardware Sales/Support
(209) 745-1401 Fax: (413) 714-2833
 
It's also possible that the script is somehow running under a different shell. Bourne shell (/bin/sh) will treat ~ as ~. Korn or C shells will replace it with the current user's home directory unless it is escaped, as you have done when you fixed the script. Annihilannic.
 
Annihilannic,

That's the answer! The fax interface script must have started running under ksh after running hpnpcfg as root under ksh. Hpnpcfg restarts lp services to activate the new interface. The new printer was the first printer added through hpnpcfg since the upgrade in January. I had changed root's shell to ksh at that time. Previously, the lp services had started from boot time under the Bourne shell.

Thanks for helping me answer why it had been working for over a month since the upgrade.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top