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 | +----------------------------------------------------------------------------+
omerzu@quando.quantum.de (Thomas Omerzu) (08/23/90)
In article <1311@eastman.UUCP> gerwitz@hpcore.kodak.com (Paul Gerwitz) writes: |question is "why won't this one script work on both machines. |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 |Works on HP-UX |DOES NOT WORK on Ultrix | |#!/bin/csh -f |set title="`tee temporary | sed -e '/^Subject: /\\!d \\ | s/Subject: //'`" |echo $title Well, _both_ scripts won't work on SUNs; I tested SUN OS 3.3, 3.5 and 4.0.3. Obviously some sed's don't like commands being seperated the way you do it, and there seem to be different ways for various csh's to interpret lots of backslashes at the end of a line. The following script uses ';' to seperate sed-commands and will work on HP-UX as well as Ultrix and SUN-OS: #!/bin/csh -f # Command to print stdin with a Subject: line set title=`tee temporary | sed -e '/^Subject: /\\!d;s/Subject: //'` echo $title -- *-----------------------------------------------------------------------------* Thomas Omerzu UUCP: ...!unido!quando!omerzu / omerzu@quando.uucp Quantum GmbH, Bitnet: UNIDO!quando!omerzu / omerzu%quando@UNIDO(.bitnet) Dortmund, Germany Internet: omerzu@quando.quantum.de