HDTenEightyP/NetNews huggingface dataset:
From: rahner@iscnvx.lmsc.lockheed.com (Mark Rahner)
Subject: Re: rshing Ultrix xterms
Organization: Lockheed Missiles and Space Co.
X-Newsreader: Tin 1.1 PL4
Date: Wed, 2 Sep 92 21:33:41 GMT

Hello Again,

I would like to thank all of those kind souls who took the time to
respond to my post.  Allow me to summarize what I now know about
rshing xterms.  For many if not most systems, the following works:

  rsh remote_host "/usr/bin/X11/xterm -ls -display $DISPLAY </dev/null >/dev/null 2>&1"

On many Ultrix systems, and possibly on some Sun systems, the rsh
daemon leaves other files open.  There is great confusion as to
which file descriptors might be associated with these files.  Several
people suggested that file descriptors 6 and 7 were the culprits.
Another implicated file descriptors 4, 6, 8, 10, 11 and 12.  On our
Ultrix systems, file descriptor 8 was found guilty.  The safest
ksh or sh shell-only solution is to use something like

  rsh remote_host "/usr/bin/X11/xterm -ls -display $DISPLAY </dev/null >/dev/null 2>&1 3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&-"

Of course, this doesn't help if the problem involves file descriptors
greater than 9.  In this case, you should either use a shell like bash
that allows you to close two digit file descriptors as well or use
something like 

  rsh remote_host "closeall /usr/bin/X11/xterm -ls -display $DISPLAY"

where the following closeall.c is provided courtesy of Michael Cook:

  #include <sys/param.h>
  #include <fcntl.h>

  int main(int argc, char **argv)
  {
      int i;

      for (i = 0; i < NOFILE; i++)
          close(i);
      open("/dev/null", O_RDONLY);
      open("/dev/null", O_WRONLY);
      dup(1);
      execvp(argv[1], argv + 1);
  }

Finally, IMHO, the answer to FAQ 3.2 should be ammended to include
this information about possible additional open files.

Thanks again to all.  You are a great resource.

-- 
Mark V. Rahner   rahner@lmsc.lockheed.com
Xref: sparky comp.unix.shell:3722 comp.unix.questions:10591
From: steiny@steiny.com (Don Steiny)
Newsgroups: comp.unix.shell,comp.unix.questions
Subject: Re: Shell Scripts vs. C programs
Keywords: shell script, C
Date: 1 Sep 92 02:48:12 GMT
Organization: Don Steiny Software

nurban@tjhsst writes:


>I've heard that if at all possible, code a program as a shell script
>rather than coding it in C.  Can someone explain the rationale behind
>this philosophy?

	BZZZ - shell scripts are non-portable, there is no error checking,
and they have many other problems.    For very short programs shell 
might be better, but in general C is better for many reasons.

-don
-- 
Don Steiny
Don Steiny Software
Santa Cruz, CA 95060
(408) 425-0382
From: geoff@world.std.com (Geoff Collyer)
Newsgroups: comp.unix.shell
Subject: Re: How to empty a file
Date: 2 Sep 92 02:20:45 GMT
Organization: The World @ Software Tool & Die

Larry Gilmore:
>When I had to ensure a zero-length file, I used:
>
>cat /dev/null > foofile

What's wrong with ">file" (or ": >file" for you csh users)?
-- 
Geoff Collyer		world.std.com!geoff, uunet.uu.net!geoff

``Leave the evil grasping to us.'' - A. L. Arms, UNIX licensing, WECo.
Newsgroups: comp.unix.shell
From: Harald.Eikrem@delab.sintef.no
Subject: Re: If shell command switches.
Organization: SINTEF DELAB, Trondheim, Norway.
	<22412@sybase.sybase.com> <4755@daily-planet.concordia.ca>
	<BAS.92Aug18100206@carlo.phys.uva.nl>
Date: 25 Aug 92 23:08:16

! (Some shells have a builtin test, but these take at least the switches
! of the system test and if there are more the shell manual should
! mention them.)

There are even OS'es (well HP-UX, maybe others) that do NOT provide a
separate 'test' command (external to /bin/sh, that is).
 
! Bas de Bakker.

  ~~harald E.
From: probreak@chester.ksu.ksu.edu (James Michael Chacon)
Newsgroups: comp.unix.shell
Subject: Re: How can I rm a file with a '&' ????
Date: 4 Sep 1992 01:19:59 -0500
Organization: Kansas State University
NNTP-Posting-Host: chester.ksu.ksu.edu

albani@cadlab.sublink.org (Lanfranco Albani) writes:

>hinz@picard.med.ge.com (David Hinz Mfg 4-6987) writes:
>:Well, the following works on MY system (Sun 4.1.1):
>:
>:rm 'big&cow'
>:
>:as someone else had mentioned.  Perhaps NOGLOB has to be set, though.

In csh, this works fine:

1:17am:chester:/tmp>cat > big\&cow
lll1:17am:chester:/tmp>ls big*
big&cow
1:17am:chester:/tmp>rm big\&cow
1:17am:chester:/tmp>ls big*
ls: No match.
1:17am:chester:/tmp>

Just remember most funny characters can be replaced with \(funny char) 


-----------------------                              ---------------------------
-Oh the joy of finding-       James Chacon           -probreak@matt.ksu.ksu.edu-
-That last pizza slice-                              ---------------------------
-----------------------				     ---------------------------
From: kcw@reef.cis.ufl.edu (Ken Whedbee)
Newsgroups: comp.unix.shell
Subject: Need rot13 script
Date: 2 Sep 92 14:08:16 GMT
Distribution: na
Organization: Univ. of Florida CIS Dept.


Hi -

Can somebody send me a simple shell script that can convert a
text file back and forth between rot13 ?

Many thanx!

-- 
Ken Whedbee                  Internet:  kcw@reef.cis.ufl.edu
University of Florida        UUCP:      ..!uflorida!bikini.cis.ufl.edu!kcw
                             BITNET:    kcw@ufpine
"C Code.  C code run.  Run, code, run... PLEASE!!!"  -- Barbara Toungue
Newsgroups: comp.unix.shell
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: C shell nested 'if' problem
Originator: tchrist@pixel.convex.com
Date: Fri, 28 Aug 1992 13:44:44 GMT
Distribution: usa
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: Convex Computer Corporation, Colorado Springs, CO
Keywords: csh
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of darrell@netcom.com (Darrell Sell):
:I have a csh problem with nested if--else if--else statements.  The 
:example below, gives the expected branching behavior, only if the parens
:are removed from the first inner if expression.  With the parens
:it gets confused if the first if expression is false.
:
:Books like "Unix in a Nutshell" or "The Unix C Shell Field Guide" or the
:csh man page don't say anything on the topic.

Ah, but csh.whynot certainly does!

    COMMAND ORTHOGONALITY

	Stupid parsing bugs

	    White space can matter:
		if(expr)
	    may fail on some versions of csh, while
		if (expr)
	    works!


Maybe I should make this a periodic posting?

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist

	    "AT&T -- anything better is illegal."
		  -- Keith Lofstrom, comp.unix.bsd, "AT&T sues BSDI" thread
From: friedman@gnu.ai.mit.edu (Noah Friedman)
Newsgroups: comp.unix.shell
Subject: Re: file removal problem solved.
Date: 29 Aug 92 05:08:51 GMT
Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
In-reply-to: vidya-v@acsu.buffalo.edu's message of 27 Aug 92 04:15:56 GMT

In article <BtMJuK.KEH@acsu.buffalo.edu> vidya-v@acsu.buffalo.edu (vidyaranya) writes:
>The solution I finally used came from our system administrator.  I had
>already tried the 'rm -i' and rm A* options and posted when they failed.
>
>The solution I used needed a simple C program and an Octal
>dump of the filename to specify in the C program.
>Here it is:
>
>[ bletcherous C program mercifully deleted ]


   Your system ambiguator ought to be shot.
From: posse@masg6.epfl.ch (Christian Posse)
Newsgroups: comp.unix.shell
Subject: tcsh completion bug on Silicon Graphics
Date: 4 Sep 92 08:45:23 GMT
Organization: Swiss Federal Institute of Technology



TCSH COMPLETION BUG AND STRANGE WARNING MESSAGE WITH FLAG __STDC__
------------------------------------------------------------------

Hi tcsh gurus,

I have implemented the 6.02 version of tcsh on our SGIs (INDIGO and
4D35 running IRIX 4.0.3 or 4.0.4).

I have found the following bug concerning the selective completion.

> complete xdvi 'n/*/f:*.dvi/'
> xdvi [TAB] 
gives all files ending with .dvi BUT also all sub-directories! In fact the
parameter f for files in the complete definition does not work in the
sense that directories appear when the f parameter is used for defining
selective completion.

Has anyone encountered the same problem ? And how to correct this feature ?

Many thanks in advance for your answers.

Christian.

P.S. For the conceptors of tcsh : In the Ported file, it is written that
for SGI, we must use the CFLAGS -D__STDC__. Why ? Without this flag, I have
a clean compilation while introducing -D__STDC__ I obtain the following warning
messages, for each compilation of *.c files. For example :

cc -D__STDC__ -O -prototypes -cckr -float  -I/usr/include -I.   
	-DSYSV -DMALLOC_0_RETURNS_NULL -DFUNCPROTO -DNARROWPROTO 
	-DCONFIGH=\"config/config.sgi\"     -c sh.c
ccom: Warning: ./sh.decls.h, line 310: function adrof1 now has prototype;   
      	a) earlier declaration did not or   
	b) function was called before declaration or definition
      
	extern    struct varent    *adrof1         (Char *, struct varent *);
      	--------------------------------------------------------------------^


Once again, thanks for help in this.

Regards.

-------------------------------------------------------------------------------
     ____/  __  /  ____/   /   Christian POSSE
    /      /   /  /       /    Swiss Federal Institute of Technology
   ____/  ____/   ____/  /     DMA-Ecublens                                   
  /      /       /      /      CH-1015 Lausanne (Switzerland)
_____/ _/      _/     _____/   
  			       e-mail : posse@masg6.epfl.ch  or
					posse@dma.epfl.ch

 ... Trying to establish voice contact ... please yell into keyboard ....
-------------------------------------------------------------------------------




Newsgroups: comp.unix.shell
From: posse@masg6.epfl.ch (Christian Posse)
Distribution: world
Date: Fri Sep  4 08:10:30 1992 GMT
Followup-To: 
Organization: Swiss Federal Institute of Technology
Subject:tcsh completion bug on Silicon Graphics
Keywords:


TCSH COMPLETION BUG AND STRANGE WARNING MESSAGE WITH FLAG __STDC__
------------------------------------------------------------------

Hi tcsh gurus,

I have implemented the 6.02 version of tcsh on our SGIs (INDIGO and
4D35 running IRIX 4.0.3 or 4.0.4).

I have found the following bug concerning the selective completion.

> complete xdvi 'n/*/f:*.dvi/'
> xdvi [TAB] 
gives all files ending with .dvi BUT also all sub-directories! In fact the
parameter f for files in the complete definition does not work in the
sense that directories appear when the f parameter is used for defining
selective completion.

Has anyone encountered the same problem ? And how to correct this feature ?

Many thanks in advance for your answers.

Christian.

P.S. For the conceptors of tcsh : In the Ported file, it is written that
for SGI, we must use the CFLAGS -D__STDC__. Why ? Without this flag, I have
a clean compilation while introducing -D__STDC__ I obtain the following warning
messages, for each compilation of *.c files. For example :

cc -D__STDC__ -O -prototypes -cckr -float  -I/usr/include -I.   
	-DSYSV -DMALLOC_0_RETURNS_NULL -DFUNCPROTO -DNARROWPROTO 
	-DCONFIGH=\"config/config.sgi\"     -c sh.c
ccom: Warning: ./sh.decls.h, line 310: function adrof1 now has prototype;   
      	a) earlier declaration did not or   
	b) function was called before declaration or definition
      
	extern    struct varent    *adrof1         (Char *, struct varent *);
      	--------------------------------------------------------------------^


Once again, thanks for help in this.

Regards.

-------------------------------------------------------------------------------
     ____/  __  /  ____/   /   Christian POSSE
    /      /   /  /       /    Swiss Federal Institute of Technology
   ____/  ____/   ____/  /     DMA-Ecublens                                   
  /      /       /      /      CH-1015 Lausanne (Switzerland)
_____/ _/      _/     _____/   
  			       e-mail : posse@masg6.epfl.ch  or
					posse@dma.epfl.ch

 ... Trying to establish voice contact ... please yell into keyboard ....
-------------------------------------------------------------------------------
From: ramakris@CSGRAD.CS.VT.EDU (S.Ramakrishnan)
Newsgroups: comp.unix.shell
Subject: Distinguish between numeric & nonnumeric char strings in shell ?
Date: 4 Sep 92 07:02:38 GMT
Organization: VPI&SU Computer Science Department, Blacksburg, VA


 How does one distinguish between a number and a nonnumeric
 character using shelltools (sh/csh, awk, sed, expr, etc) ? 
 I am trying to validate the IP address typed in by the user. 
 I isolate the four components and check each one to see if lies 
 within the legal range (0..255). In the event the user types, say, 
 tom.jack.joe.jim, I want to be able to flag an error. However the 
 IF statement, marked (+) in the fragment below, fails even if a 4 
 component string such as "tom.jack.joe.jim"  is entered. 
 Any suggestions ?

 Encl:
	#!/bin/sh
        ...
	while test "$ip" = ""
	do
          echo "    IP Address = "
	  read ip
          if [ "$ip" != "" ]
	  then
              cnt=`echo $ip | awk -F'.' '{ print NF }'`
              one=`echo $ip | awk -F'.' '{ print $1}'`
              two=`echo $ip | awk -F'.' '{ print $2}'`
              thr=`echo $ip | awk -F'.' '{ print $3}'`
              fou=`echo $ip | awk -F'.' '{ print $4}'`
#(+)
              if [ $cnt -ne 4 -o $one -gt 255 -o $two -gt 255 -o $thr -gt 255 -o $fou -gt 255 ]
              then
	        echo ""
                echo "*** Invalid IP Address Format: Please Retype"
	        echo ""
	        ip=""
              fi
	  fi
        done
	...

---
S Ramakrishnan, CS Dept, McBryde Hall, VaTech, Virg.
Newsgroups: comp.unix.shell
From: rahner@iscnvx.lmsc.lockheed.com (Mark Rahner)
Subject: rshing Ultrix xterms
Organization: Lockheed Missiles and Space Co.
X-Newsreader: Tin 1.1 PL4
Date: Tue, 1 Sep 92 19:23:15 GMT

Hello World,

I am having trouble rshing an xterm when the remote xterm is started
under Ultrix V4.2 (Rev. 96) UWS V4.2 (Rev. 272).  Specifically, I can't
prevent rsh from hanging around until the remote xterm has completed.
I am using the Korn shell on all of the networked systems.  It is
particularly important to me that the remote xterm be independent of
the local xterm.  That is, I must be able to terminate the local xterm
without affecting the remote xterm.

And now, a preemptive quote from FAQ 3.2:
>
> 2)  How do I use "rsh" without having the rsh hang around until the
>     remote command has completed?
>
>     (stuff deleted)
>
>     If you use sh on the remote machine:
>
> 	    rsh machine -n 'command >/dev/null 2>&1 </dev/null &'
>
>     Why?  "-n" attaches rsh's stdin to /dev/null so you could run the
>     complete rsh command in the background on the LOCAL machine.
>     Thus "-n" is equivalent to another specific "< /dev/null".
>     Furthermore, the input/output redirections on the REMOTE machine
>     (inside the single quotes) ensure that rsh thinks the session can
>     be terminated (there's no data flow any more.)
>
>     Note: The file that you redirect to/from on the remote machine
>     doesn't have to be /dev/null; any ordinary file will do.
>
>     In many cases, various parts of these complicated commands
>     aren't necessary.

When rshing to RS/6000s, SGIs, and AIX/ESAs, the following works great:

  rsh remote_host \
    "/usr/bin/X11/xterm -ls -display $DISPLAY </dev/null >/dev/null 2>&1"

Notice that I didn't use rsh's -n option and I didn't put the remote
xterm in the background.  This even works when I rsh FROM an Ultrix box
to something else.  However, if I try to rsh TO an Ultrix box from
anywhere, even an Ultrix box, I have no luck regardless of how I mangle
the command.  The only way that I have been able to get this to pop a
usable remote xterm without hanging the local xterm is to put rsh (not
the xterm) into the background.  This results in an rsh that hangs around.

Am I doing something wrong?  Is Ultrix doing something wrong?  Does
this happen to you too?  Any ideas would be greatly appreciated.
Thanks in advance.

P.S.  What should I expect from a machine that doesn't even ship with
      a Standard C compiler?  Does DEC do this to be compatible with
      VMS?  :-)  Who buys these things for us, anyway?

-- 
Mark V. Rahner   rahner@lmsc.lockheed.com
Newsgroups: comp.unix.shell
From: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Subject: Re: rshing Ultrix xterms
Reply-To: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Organization: Motorola Codex, Canton, MA
Date: Wed, 2 Sep 1992 15:01:29 GMT

In article <mcook.715394232@fendahl.dev.cdx.mot.com>, mcook@fendahl.dev.cdx.mot.com (Michael Cook) writes:
|>rahner@iscnvx.lmsc.lockheed.com (Mark Rahner) writes:
|>
|>>Hello World,
|>
|>>I am having trouble rshing an xterm when the remote xterm is started
|>>under Ultrix V4.2 (Rev. 96) UWS V4.2 (Rev. 272).  Specifically, I can't
|>>prevent rsh from hanging around until the remote xterm has completed.
|>>I am using the Korn shell on all of the networked systems.  It is
|>>particularly important to me that the remote xterm be independent of
|>>the local xterm.  That is, I must be able to terminate the local xterm
|>>without affecting the remote xterm.

Don't forget that your DECstation is probably only licensed to have two
users logged on to it simultaneously - if you start using rsh xterm then
you can easily exceed this limit (if you care about such things ;-) and you
might have DEC engineers waiting in the parking lot for you some night...

Lezz....
Xref: sparky comp.unix.shell:3776 comp.unix.questions:10655
From: sweh@spuddy.uucp (Stephen Harris)
Newsgroups: comp.unix.shell,comp.unix.questions
Subject: Re: Shell Scripts vs. C programs
Keywords: shell script, C
Date: 1 Sep 92 22:20:41 GMT
Organization: Spuddy's Public Usenet Domain

In article <119@steiny.com> steiny@steiny.com (Don Steiny) writes:
>	BZZZ - shell scripts are non-portable, there is no error checking,
>and they have many other problems.    For very short programs shell 
>might be better, but in general C is better for many reasons.

Of course!  Thats why the 1000+ lines of ksh script I have written and is
running on three different systems (SunOs4.1.1, Convergent S/80 Ctix, Altos
3068 SVR2.2) and used to run under Ultrix 4.1 was so hard to get working....
NOT!

And it is so easy to modify, enhance, understand!
And this program has been running now for over 1 year....

In fact ksh is now my primary programming "language" - I keep kicking myself
when my occaisioanl C program has comment lines beginning with a # :-)

Yes, there *are* times where ksh is not suitable for everything, but a main
ksh program with a couple of special C utilities solve 99% of my problems.

With something as powerful as ksh, all you need is the shell, and your programs
will run virtually anywhere.

Sounds like some arguments I've heard for perl...:-)
-- 
                               Stephen Harris
               sweh@spuddy.uucp    ...!uknet!axion!spuddy!sweh

 * Meeeeow ! Call Spud the Cat on > +44 203 638780 < for free Usenet access *
From: hsc@sybase.com (Howard Cohen)
Newsgroups: comp.unix.shell
Subject: Re: How can I rm a file with a '&' ????
Date: 26 Aug 92 23:01:39 GMT
Organization: Sybase, Inc.

Ok, some facts.  It can be hard to remove files that contain certain 
characters, becuase of side-effects of their special meanings.  For example,
try to remove a file that begins with a dash (-).  Surprise! Not so easy.

First, I never write tools which create problem filenames.  So I tend not
to need to handle them in the tools I write.  However, its easy enough to
create problem filenames through mistakes, typos (especially from vi), etc.
So the need does arise for me to address problem filenames.

What I generally do for a one-time-only problem is to create a simple
C program like this:

	main()
	  {
	    unlink("weirdfilename");
	  }

Obviously, this isn't a great solution if you need to run it on lots of
different machines, or have lots of different files to remove.  Several
others have posted legitemate reasons to avoid proliferating tiny
specialized C programs, and I agree with them all.  I only use this
technique when I have a single problem file to remove.  Then I quickly remove
the C source and executable.  If I'd be tempted to save it, then I'd know
I picked the wrong solution.

Another useful technique is to rename the directory containing the problem
file(s), and create a new directory by the original name.  Then mv the
files from the old directory into the new one, leaving behind what you don't
want.  This works well too, and can be done in a shell script fairly easily.

Its funny though, when people ask me how to remove a strange filename, and
I show them my unlink trick, they look pained, as though I'd made a bad pun.  
Then I can't help pointing out that this is my "main" solution to this kind
of problem...  

:) 

	Howard
-------------------------------------------------------------------------------
  Howard "I wood if I could" Cohen
  hsc@sybase.com  {pacbell,pyramid,sun,{uunet,ucbvax}!mtxinu}!sybase!hsc
  Sybase, Inc.    6475 Christie Avenue, Emeryville, CA 94608, 510-596-3406 
Newsgroups: comp.unix.shell
From: Harald.Eikrem@delab.sintef.no
Subject: Re: Parameter Passing
Organization: SINTEF DELAB, Trondheim, Norway.
Date: 25 Aug 92 22:48:15

rgasch@nl.oracle.com (Robert Gasch) went:

! I have written a shell script which accepts one parameter. The first
! thing it does after making sure that it is /bin/sh and not some
! other shell is check if the parameters are OK.
! If I call it as
! 	ap STRING_ARG
! 	sh ap STRING_ARG
! everything is fine. The parameter is recognized and life is great.
!
! Here comes the confusion: As soon as I call it as
! 	. ap STRING_ARG
! the parameter is not recognized anymore. Even supplying it with 
! 2 or more parameters does not change the fact that $# is equal to 0. 

In (Bourne) sh:

  inline_proc() { . shell_proc $@; }
  inline_proc args....

should arrange for argument passing within the current shell invokation.
(Anybody care to explain why?)

  ~~harald E
Newsgroups: comp.unix.shell