gerwitz@hpcore.kodak.com (Paul Gerwitz) (08/09/90)
Here is an interesting phenomena for you u**x hackers. Below are two variations of the same script which takes a news article and strips out the subject line for use later. The second variation was created because the csh on a different machine would not take the origonal script. The question is "why won't this one script work on both machines. File 1 Origonal script works on Decstation 3100 @ Ultrix 3.0 DOES NOT WORK on HP835 at HP-UX 7.0 #!/bin/csh -f # Command to print stdin with a Subject: line set title=`tee temporary | sed -e '/^Subject: /\\!d\\\ s/Subject: //'` echo $title ------------------------------------------------------- File 2 Modified origonal Works on HP-UX DOES NOT WORK on Ultrix #!/bin/csh -f set title="`tee temporary | sed -e '/^Subject: /\\!d \\ s/Subject: //'`" echo $title The script is run as such: file1 < testdata Here is the test data file: From eastman!kodak!rochester!cornell!mailrus!cs.utexas.edu!uunet!pilchuck!ssc!tad Tue Aug 7 08:17:53 1990 Article 12754 of rec.ham-radio: Path: eastman!kodak!rochester!cornell!mailrus!cs.utexas.edu!uunet!pilchuck!ssc!tad >From: tad@ssc.UUCP (Tad Cook) Newsgroups: rec.ham-radio Subject: AMSAT News, 8/4/90 Keywords: Ham satellite news Message-ID: <971@ssc.UUCP> Date: 6 Aug 90 05:29:45 GMT Organization: very little Lines: 682 -- +----------------------------------------------------------------------------+ | Paul F Gerwitz WA2WPI | SMTP: gerwitz@kodak.com | | Eastman Kodak Co | UUCP: ..uunet!atexnet!kodak!eastman!gerwitz | +----------------------------------------------------------------------------+
wk@hpirs.HP.COM (Wayne Krone) (08/10/90)
This isn't the question you asked, but FYI either one of the following scripts should work on both machines. Both eliminate the quoted newline which appears to be handled differently by the two csh's. Replace the quoted newline by a second "-e": #!/bin/csh -f set title=`tee temporary | sed -e '/^Subject: /\\!d' -e 's/Subject: //'` echo $title Reduce the sed script down to a single command: #!/bin/csh -f set title=`tee temporary | sed -n -e 's/^Subject: //p'` echo $title Wayne