HDTenEightyP/NetNews huggingface dataset:
From: guenther@stolaf.edu (Philip A Guenther)
Subject: Re: How to port this sh script to csh script ?
Organization: Academic Computing Center, St. Olaf College
Distribution: usa
Date: Mon, 11 Jan 1993 06:05:37 GMT

   Two questions for csh experts :

   1. How to port this sh script to csh script ?

"Luke, Don't give in to the csh side of shell programming!"

   #!/bin/sh
   while read line_by_line 
   do
	   echo "Do something for $line_by_line"
   done < input_file

   2. Can I use "line" command in my previous example csh script ?
      If answer is 'Yes', then How ?

Yes, but it's tricky.  I'm inclined to tell you "No" just because it's
so bad, but here's a way.... (Not for the quesy stomached)

#!/bin/csh
set t1 = /tmp/1tmp$$
set t2 = /tmp/2tmp$$
set t3 = /tmp/3tmp$$
set t4 = /tmp/4tmp$$
cp input_file $t1
echo 0 >$t2
while ( `cat $t2` )
  (line > $t3; echo $status > $t2; cat > $t4) < $t1
  mv $t4 $t1
  set line_by_line = `cat $t3`
  echo "Do something for $line_by_line"
end

The first temp file holds the not yet read stuff, the second holds the
exit status of the line command, the third the output of the line
command, and the forth is the stuff not yet read while we read the
first line of the first temp.  Wheew!

  Now while I'm sure some of that could be made nicer, it still
doesn't hide the fact that the Bourne shell version is cleaner,
*clearer*, nicer, faster, able to work on systems that don't have csh
(not all do you know!), etc, etc.  So the *real* answer to your
question is "Yes, but you don't want to."  Can you explain why you
would *want* to?

   Thank you very much.
   -Jane

You're welcome (I think)

Philip Guenther
--
guenther@stolaf.edu (Philip Guenther)       | The ACC might agree with me,
Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
St Olaf College, Northfield, MN 55057       | you never know... :-| :-( :-)
"Life makes sense?  LIFE MAKES SENSE!?!?  Where do people get these ideas?"
Newsgroups: comp.unix.shell
From: schwager@mike.cs.uiuc.edu (Mike Schwager)
Subject: Exiting ksh with a running job
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
Date: Wed, 13 Jan 1993 01:29:44 GMT


Howdy,
Quick question:  why won't ksh let me exit if I have a job running thusly:

     command > /dev/null 2>1 &

I should say, I can exit but it will kill the job!  Can I get ksh to be
more kind?
Thanks
-Mike
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.shell
Subject: Re: Extracting regular expressions using egrep/sed/...
Date: 6 Jan 93 14:07:20 GMT
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY

In article <1993Jan5.135145.28405@infolog.se>, mich@lin.infolog.se (Thomas Michanek) writes:
| 
| I have two questions concerning csh programming:

  No, you have two questions about regular expression matching.

| 1. Let's say I have a variable $var containing >1 words of text.
|    I want to know if this variable contains a specific pattern in the
|    form of a regular expression. The way I do it now is:

  The ':' operator in expr does this nicely and the status returned is 0
for match and 1 for none, no checking of output needed.

| 2. Now that I know the variable contains what I want, I want to extract
|    the part(s) of the variable value that matches the regular expression.
|    Let's say I'm looking for integers (i.e. [0-9]+) and $var contains:

  Again, expr has the ability to extract matching parts of complex
regular expressions.

| Any pointers are much appreciated!

  There is a lot more to expr than just arithmetic, and if you need
portability it useful. As nice as ksh and perl are, it's nice to do
things in a way which will work on all machines!
-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.
Newsgroups: comp.unix.shell,comp.unix.programmer
From: mustafa@seas.smu.edu (Mustafa Kocaturk)
Subject: Re: A quoting problem.
Summary: Using escape sequences in Unix and literals in C
Keywords: SVR4, Bourne shell, quoting filenames.
Followups-To: comp.lang.c
Organization: SMU - School of Engineering & Applied Science - Dallas
Date: Tue, 5 Jan 1993 22:35:44 GMT

In article <1ialduINNe7o@chnews.intel.com> bhoughto@sedona.intel.com (Blair P. Houghton) writes:
>In article <lkh5trINNvf@exodus.Eng.Sun.COM> richb@stard.Eng.Sun.COM (Rich Burridge) writes:
>>strcpy(cmd, "FILES='file file1 file2';export FILES;rm $FILES") ;
>>...
>>execl("/bin/sh", "sh", "-c", cmd, (char *) 0) ;
>>...
>>Now the problem is how to correct quote the "cmd" string to handle all
>>possible filenames. Can this be done?
>
>Not trivially.
>
>Since you're sending the output to the shell your program
>has to be as smart as you would have been had you typed the
>command-line to the shell yourself.
>
>That is, the program would have to put a backslash in all
>the proper places in filenames that require escaped characters.
>
>The simplest way to do this would be to put a backslash in
>front of every character, but you then conflict with C's
>interpretation of certain escape sequences within strings
>(e.g., "\n" and "\"").
>
>That is, sometimes it takes two backslashes, sometimes one,
>but most of the time none.
>
>				--Blair
>				  "That depends..."

The idea of preceding each character with a  backslash  does  not
pose  a  problem  as far as the C string interpretation rules are
concerned: C will interpret escape  sequences  in  literals,  and
only during compilation.  The string under consideration is not a
literal; it is an array filled in by the  program  while  it exe-
tes.  C  will never have to interpret that string, except for the
terminating null character that is interpreted by the execl func-
tion.  (Followups to comp.lang.c)

This leaves you with one less reason for extra  backslashes  than
suggested above.


Best regards,

Mustafa
-- 
Mustafa Kocaturk   mustafa@seas.smu.edu  EE Dept., Room 305A, Caruth Bldg.
Home: 214-706-5954  Office: 214-768-1475  SMU Box 753190, Dallas, TX 75275
From: bill@twg.bc.ca (Bill Irwin)
Newsgroups: comp.unix.shell
Subject: Re: How to automount an NFS?
Date: 6 Jan 93 07:31:19 GMT
Reply-To: bill@twg.bc.ca (Bill Irwin)
Distribution: na
Organization: The Westrheim Group, Vancouver, B.C., Canada

ta2321s@dunix.drake.edu (Terry Asher alias -       The Penguin) writes:

:    I am trying to automount wuarchive.wustl.edu on /stl.  When I give the
: command automount -f auto -M /stl and then cd to /stl and say ls I get nothing.
: My auto file in /etc looks like this:
: /stl           -ro             wuarchive.wustl.edu:/archive/graphics/gif
: I have also tried the command:
: automount -M /stl and still no go.
:    I want to automount rather than mount because if wuarchive goes down then
: it adversely affects my Unix system.  Thanks for any help.

I am just getting started will NFS, so this comment may seem
bizarre.  Are you sure that the remote system is exporting the
directory you are trying to mount to your system?
-- 
Bill Irwin    -       The Westrheim Group     -    Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!twg!bill            (604) 431-9600 (voice) |     Your Computer  
bill@twg.bc.ca            (604) 430-4329 (fax)   |    Systems Partner
From: msp@msen.com (Jerry Foster)
Newsgroups: comp.unix.shell
Subject: Print Graphics files
Date: 11 Jan 1993 14:11:51 GMT
Organization: Msen, Inc. -- Ann Arbor, Michigan
NNTP-Posting-Host: garnet.msen.com
X-Newsreader: TIN [version 1.1 PL8]



We are looking for a command line utility that will print various graphics
files (gif, tiff, dwg, dxf, etc.).  Either commercial or public domain
will do.  We are running SCO Unix 3.2.4 with Hewlet Packard laserjets and
a deskjet color.   Does anyone know if such a utility exists?  

Thanks in advance,

Jerry Foster



--
  //  Jerry Lee "3P"
\x/   e-mail: jfos@msp.com
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.shell
Subject: Re: How to make Restrict Shell more safely?
Date: 7 Jan 93 17:14:40 GMT
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY

In article <1993Jan6.135639.1668@gmuvax2.gmu.edu>, wvarga@gmuvax2.gmu.edu (Wilson Varga) writes:

| There is a commercial product, CENTRUS UX, that solves all of this by
| keeping end-users within a menu system.  What the resrticted class of
| end-users is permitted to do/not do is entirely under the control of
| the system administrator.  Access to any of the unix shells is also
| effectively eliminated, without restricting the functionality of
| applications such as vi.  Contact the company directly for more
| information.  I know that CENTRUS is currently available for HP-UX, but
| the company is seeking to compile for other versions of unix.
| Contact uss@uii.com.

  Or you can use the menu system I posted to the net some years ago.
However, if you give access to vi, unless you do something to vi to
restrict it, vi will give access to a full unrestricted shell.
-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.shell
Subject: Re: How to make Restrict Shell more safely?
Date: 5 Jan 93 16:54:46 GMT
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY

In article <1ibbd7INNiml@mudos.ann-arbor.mi.us>, mju@mudos.ann-arbor.mi.us (Marc Unangst) writes:
| In article <1993Jan4.200035.7840@crd.ge.com> davidsen@crd.ge.com (bill davidsen) writes:
| >Followups please note any major holes in this (I've run it for years, so
| >I probably have a fix I didn't mention).
| 
| Hmm.  Is vi part of the /guest/bin environment?  If so, all the user
| has to do is "vi foo", then do ":set shell=/bin/sh" and ":!/bin/sh".
| Presto, they have an unrestricted shell.

  I mentioned this in item 4, you need to determine the security of each
program in bin.

-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.
Newsgroups: comp.unix.shell
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: File Problem.
Organization: Sequoia Peripherals, Inc.
Distribution: comp
Date: Sat, 9 Jan 93 16:39:56 GMT

In article <1993Jan9.005821.20072@cs.sandia.gov> jhgreen@cs.sandia.gov (Jethro H. Greene) writes:
>In article <WRASMAN.93Jan8164326@duncan.utkcs> wrasman@duncan.utkcs (Mirror Mirror on the wall) writes:
>>I seem to have accidently created a file that starts out with
>>a - . I can't get rm to get rid of it and I can mv to another file
>>name. SO does anyone know how to get rid of a file like this.
>
>The shell thinks that when you type '-', you are giving the command options.

The shell has no idea what '-' means, '-' is not a shell
meta-character. So the shell just passes the '-' along
to rm. It is rm that thinks you are giving it options,
not the shell.


-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.unix.shell
From: mark@drd.com (Resident.Alien)
Subject: equivalent of csh: cdpath in ksh?
Organization: DRD Corporation
Distribution: na
Date: Wed, 6 Jan 1993 13:24:16 GMT

I'm think of making the switch from csh to ksh in order to be able to
have a shell that works the same on all systems that I visit (H-P's csh
ain't nothing like Honeywell/Bull's csh which ain't nothing like Sun's
csh, unfortunately).

The one feature that I've grown very fond of in csh is the cdpath.  Does
ksh support a similar notion?

-- 
mark.lawrence@drd.com                                     (918)743-3013
DRD Corp., 5506 South Lewis Ave., Tulsa, OK 74105         (918)745-9037 fax
Newsgroups: comp.unix.shell
From: mxcrew@mx2306.gud.siemens.co.at (The MX-Crew)
Subject: Re: File Problem.
Date: Tue, 12 Jan 1993 17:12:59 GMT
Distribution: comp
Organization: SIEMENS Austria Corp., A-1100 Wien, Gudrunstr. 11
X-Newsreader: Tin 1.1 PL5

Mirror Mirror on the wall (wrasman@duncan.utkcs) wrote:
: I seem to have accidently created a file that starts out with
: a - . I can't get rm to get rid of it and I can mv to another file
: name. SO does anyone know how to get rid of a file like this.
: 
: 
: 
: 
: --
:   @             Internet:wrasman@cs.utk.edu, as766@cleveland.freenet.edu 
:  (!=>---        Bitnet:Razron@utkvx                                      
:  / ) Raz        Usnail: 2305 Laurel Ave #2 Knoxville,TN 37916       

rm -  <filename beginning with ->
or
rm -- <filename beginning with ->

--
 +--------------------------------------------+  /-\o /-()  -- -  --   -
 | PEYERL MICHAEL, SIEMENS AG VIENNA          |  \_/ \\/ )  -- -    --
 | E-MAIL: mxcrew at mx2306.gud.siemens.co.at |       |/_\  -- -  --   -
 +--------------------------------------------+        \_/.  .  . . ........
 Honda NX500 Dominator + 588ccm racepiston
Newsgroups: comp.unix.shell
From: chris@engineer.mrg.uswest.com (Chris Fedde)
Subject: Re: ksh 1, perl 2  ksh or perl for scripting?
Organization: USWEST Marketing Resources
NntpPostingHost: engineer.mrg.uswest.com
Date: 05 Jan 93 20:25:22 GMT

In article <801@cyclone.sbi.com> bet@sbi.com (Bennett Todd @ Salomon Brothers Inc., NY ) writes:
>Actually, when it comes to clarity of code, I think Perl wins over sh or C,
[...]

I don't mean to pick on Mr Todd specifically, neither do I mean
to slight the value of any particular scripting language but...

Always use /bin/sh or compiled images for system tools.  

	did I make my point?
	chris
 
Chris Fedde, USWEST MRG, chris@mrg.uswest.com, voice +13037842823
From: Shujaat.Ali@launchpad.unc.edu (Shujaat Ali)
Newsgroups: comp.unix.shell
Subject: Problem with $*.
Date: 7 Jan 93 03:55:40 GMT
Organization: University of North Carolina Extended Bulletin Board Service


I am having this strange problem while using this line 

echo $* >> cfgargs      #where cfgargs is the filename

the input to the script is

$ cfg '9.1.1.1'

the output should give 9.1.1.1 in the cfgargs file.

The problem is that on execution one of the scripts provides the
desired result, whereas the execution of second script places a blank
line in the output file. Both the scripts are almost identical, in the
past I have also experienced difficulty printing command line parameters
like

	echo $1

The scripts are ran in ksh environment, any help is appreciated.

					Thanks,

					Shujaat.



internet: shujaat@vnet.ibm.com
--
   The opinions expressed are not necessarily those of the University of
     North Carolina at Chapel Hill, the Campus Office for Information
        Technology, or the Experimental Bulletin Board Service.
           internet:  laUNChpad.unc.edu or 152.2.22.80
Newsgroups: comp.unix.shell
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: equivalent of csh: cdpath in ksh?
Originator: lewart@rsm1.physics.uiuc.edu
Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
Organization: UIUC Physics Department
Distribution: na
Date: Wed, 6 Jan 1993 17:43:01 GMT

In article <1993Jan6.132416.12044@drd> mark@drd.com (Resident.Alien) writes:

> The one feature that I've grown very fond of in csh is the cdpath.  Does
> ksh support a similar notion?

Of course--the shell variable CDPATH.

Daniel Lewart
d-lewart@uiuc.edu
From: wrasman@duncan.utkcs (Mirror Mirror on the wall)
Newsgroups: comp.unix.shell
Subject: File Problem.
Date: 8 Jan 93 16:43:26
Organization: /canary/homes/wrasman/.organization
Distribution: comp
NNTP-Posting-Host: duncan.cs.utk.edu

I seem to have accidently created a file that starts out with
a - . I can't get rm to get rid of it and I can mv to another file
name. SO does anyone know how to get rid of a file like this.




--
  @             Internet:wrasman@cs.utk.edu, as766@cleveland.freenet.edu 
 (!=>---        Bitnet:Razron@utkvx                                      
 / ) Raz        Usnail: 2305 Laurel Ave #2 Knoxville,TN 37916       
Newsgroups: comp.unix.shell
From: mxcrew@mx2306.gud.siemens.co.at (The MX-Crew)
Subject: Re: xargs with no arguments
Date: Tue, 12 Jan 1993 15:55:23 GMT
Organization: SIEMENS Austria Corp., A-1100 Wien, Gudrunstr. 11
X-Newsreader: Tin 1.1 PL5

Mitra (mitra@pandora.sf.ca.us) wrote:
: 
: Is there any easy trick to persuade xargs not to execute if there are no
: arguments presented on stdin, I'm running it in a cron task, and often
: the command being xarg-ed will report an error if there are no arguments
: to delete/index/whatever.
: 
: - Mitra
: 

If you don't need controlmessages, redirect stdout and stderr to /dev/null

--
 +--------------------------------------------+  /-\o /-()  -- -  --   -
 | PEYERL MICHAEL, SIEMENS AG VIENNA          |  \_/ \\/ )  -- -    --
 | E-MAIL: mxcrew at mx2306.gud.siemens.co.at |       |/_\  -- -  --   -
 +--------------------------------------------+        \_/.  .  . . ........
 Honda NX500 Dominator + 588ccm racepiston
Newsgroups: comp.unix.shell
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Extracting regular expressions using egrep/
Organization: Sequoia Peripherals, Inc.
Date: Tue, 5 Jan 93 20:20:10 GMT

In article <1993Jan5.195647.19715@crd.ge.com> csdgwh@sn370.utica.ge.com (Glenn W. Hoffman) writes:

>works silently, i.e., returns only a status that you may test in the
>if command. I am not a csh programmer, but it appears that you could say
>  if (echo $var | egrep -s '<regexp>') then ...

No. The csh is looking for a boolean expression inside the
parentheses; it is not looking for the exit status of a
program like /bin/sh would do in the analogous situation.

This construct is usually written:

echo $var | egrep -s '<regexp>'
if ( $status == 0 ) then ...


-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.unix.shell,comp.unix.programmer
From: eric@giga.mks.com (Eric Gisin)
Subject: Re: A quoting problem.
Organization: Mortice Kern Systems Inc., Waterloo, Ontario, CANADA
Date: Thu, 7 Jan 1993 01:47:19 GMT

If you need to use a variable with a list of files,
then you have to have a delimiter (space) that is a valid filename char.
So you can't handle a file called "Mail box".

A clever trick to call the shell with -c that avoids quoting problems is:
	execl("/bin/sh", "sh", "-c", "$0 \"$@\"",
		"rm", "$$ 3", "it's", NULL);

The last three arguments become the shell's $0, $1, and $2,
and are not subject to quote interpretation.
The command is $0 "$@", which uses $0 (rm) as the command name,
and $1 ($$ 3) and $2 (it's) are arguments passed to rm
without word splitting or pathname expansion.
From: rolf@geoserv (Rolf Wilson)
Newsgroups: comp.unix.shell
Subject: doing commands with newgrp
Date: 8 Jan 93 22:14:50 GMT
Reply-To: rolf@geoserv.isgs.uiuc.edu
Organization: University of Illinois at Urbana


   I have some users who need to run a certain program under a secondary
group, to make sure that the files they create are accessible to the
right people. They can use the "newgrp" command, but sometimes they
forget. I thought of trying to track down all the files created, and
change them, but they are not all conveniently findable. So I wanted to
have a batch file that would do a newgrp, then run the program.
   But doing a newgrp gives you a new shell, and the rest of the batch
file is not finished until you exit the newgrp shell. This sounds like
a problem that has been solved a long time ago, but I have been unable
to find it described. Is there a standard way of doing something like
this? Please e-mail me, and I will forward answers to anyone else interested.
-- 
Rolf Wilson     Illinois State Geological Survey    rolf@geoserv.isgs.uiuc.edu
From: zzz@byron.u.washington.edu (Sample)
Newsgroups: comp.unix.shell
Subject: How does tcsh redirect error-diagnostics-stderr
Date: 11 Jan 93 13:35:29 GMT
Article-I.D.: shelley.1irt31INNmf6
Organization: University of Washington
NNTP-Posting-Host: byron.u.washington.edu

Please email me here (zzz@byron.u.washington.edu)
if you know how to redirect tcsh`s error.

/bin/sh does this by: ls . 2> ErrorFile > OutFile
but /usr/local/bin/tcsh can't do this.
I don't have a zsh.
And I like tcsh`s history features.

Jeff
Newsgroups: comp.unix.shell
From: pjh@mccc.edu (Pete Holsberg)
Subject: Re: book on shell programming
Organization: The College On The Other Side Of Route One
Date: Tue, 5 Jan 1993 01:23:24 GMT

In article <1993Jan4.171014.3369@samba.oit.unc.edu> Gary.Moh@launchpad.unc.edu (Gary Moh) writes:
=Could someone recommend a couple of books on shell programming please??

"UNIX Shell Programming" by Kochan and Wood, Hayden Publ.
Newsgroups: comp.unix.shell
From: fischer@iesd.auc.dk (Lars Peter Fischer)
Subject: Re: File Problem.
Organization: Mathematics and Computer Science, Aalborg University
Date: Wed, 13 Jan 1993 00:31:29 GMT


>>>>> "Mirror" == Mirror Mirror on the wall (wrasman@duncan.utkcs)

Mirror> I seem to have accidently created a file that starts out with
Mirror> a - . I can't get rm to get rid of it and I can mv to another file
Mirror> name. SO does anyone know how to get rid of a file like this.

Use another name for the file. The obvious choice is using
./<filename> or /where/ever/the/file/is/<filename>.

  rm ./<filename>

Remember, there are many ways to name the same file.

/Lars
--
Lars Fischer, fischer@iesd.auc.dk | It takes an uncommon mind to think of
CS Dept., Aalborg Univ., DENMARK. | these things.  -- Calvin
From: jhgreen@cs.sandia.gov (Jethro H. Greene)
Newsgroups: comp.unix.shell
Subject: Re: File Problem.
Date: 10 Jan 93 03:02:32 GMT
Distribution: comp
Organization: Sandia National Laboratories, Albuquerque, NM

In article <1993Jan9.163956.13182@leland.Stanford.EDU> dkeisen@leland.Stanford.EDU (Dave Eisen) writes:
>In article <1993Jan9.005821.20072@cs.sandia.gov> jhgreen@cs.sandia.gov (Jethro H. Greene) writes:
>>In article <WRASMAN.93Jan8164326@duncan.utkcs> wrasman@duncan.utkcs (Mirror Mirror on the wall) writes:
>>>I seem to have accidently created a file that starts out with
>>>a - . I can't get rm to get rid of it and I can mv to another file
>>>name. SO does anyone know how to get rid of a file like this.
>>
>>The shell thinks that when you type '-', you are giving the command options.
>
>The shell has no idea what '-' means, '-' is not a shell
>meta-character. So the shell just passes the '-' along
>to rm. It is rm that thinks you are giving it options,
>not the shell.
>
You're right.  Often, when I am not thinking, I use shell as a synonym for
computer.  Thank you for correcting me.

-- 
Jethro H. Greene
Massively Parallel Computing Research Laboratory,
Sandia National Laboratories, Albuquerque, New Mexico