delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/13/18:14:00

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Tue, 13 Apr 2004 18:12:20 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Christopher Spears <cspears2002 AT yahoo DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: problems with script
In-Reply-To: <20040413212742.66409.qmail@web12402.mail.yahoo.com>
Message-ID: <Pine.GSO.4.56.0404131756580.26068@slinky.cs.nyu.edu>
References: <20040413212742 DOT 66409 DOT qmail AT web12402 DOT mail DOT yahoo DOT com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Tue, 13 Apr 2004, Christopher Spears wrote:

> --- Igor Pechtchanski <xxxxxxxx AT xx DOT xxx DOT xxx> wrote:
                         ^^^^^^^^^^^^^^^^^^^
<http://cygwin.com/acronyms/#PCYMTNQREAIYR>

> > On Tue, 13 Apr 2004, Christopher Spears wrote:
> >
> > > I created the following script:
> > >
> > > #!/bin/tcsh
> > >
> > > #csh script to prepend standard input to file argument
> > > #Version 1
> > >
> > > #name temp file
> > > set tf = /tmp/ppd.$$
> > >
> > > #get argument name
> > > set dest = $argv[1]
> > >
> > > #copy standard input, $dest to $tf
> > > cat - $dest > $tf
> > >
> > > #replace original file
> > > mv $tf $dest
> > >
> > > However, when I run the script in the tcsh with the
> > > following command line:
> > > (date; du ~) | ./ppd.txt ~/disk_storage&
> > >
> > > I get a syntax error (set: Syntax Error).
> > >
> > > I posted this script on an online Linux forum.  A
> > > member copied it into vi, and it worked fine.  Is
> > > there something in Cygwin that I need to do?  I have
> > > written #!/bin/tcsh at the top, and I haved used set
> > > before in tcsh.
> >
> > Nope.  WFM in Cygwin 1.5.9, tcsh 6.12.00, Win2k.  This could be caused
> > by the presence of a control character in your script (e.g., if you
> > edited it in MS Word).  Try changing the first line to "#!/bin/tcsh
> > -x" to see exactly which commands are invoked.  Pipe stderr through
> > "cat -A" to see any special characters.
> >       Igor
>
> I changed the first line to "!/bin/tcsh -x", and then tried to run the
> script again.  Here are the results:
>
> set tf = /tmp/ppd.1316
> set dest = /home/Christopher Spears/disk_storage
> set: Syntax error
>
> So it seems the first two lines work...Right?

Nope.  The lines are printed *before* they're executed.  Your problem is
missing quotes.  This is a common pitfall in Cygwin, as spaces in
filenames are much more common in Windows than in Unix (although a space
is a valid filename character in any Unix implementation).
Change lines 10, 13, and 16 of your script to

10 	set dest = "$argv[1]"

13 	cat - "$dest" > "$tf"

16 	mv "$tf" "$dest"

respectively, and your script should work.  You should really quote
accesses to any variable that may potentially contain whitespace.

> What is stderr?

stderr is a common abbreviation of the "standard error" output stream,
usually associated with file descriptor 2 (called "diagnostic output" in
tcsh-speak).  See "man bash" (search for "REDIRECTION") or "man tcsh"
(search for "Input\/output$").
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019