delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/08/17:08:34

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: Thu, 8 Apr 2004 17:07:49 -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: writing csh scripts with cygwin
In-Reply-To: <20040408190219.19916.qmail@web12405.mail.yahoo.com>
Message-ID: <Pine.GSO.4.56.0404081507361.21641@slinky.cs.nyu.edu>
References: <20040408190219 DOT 19916 DOT qmail AT web12405 DOT mail DOT yahoo DOT com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Thu, 8 Apr 2004, Christopher Spears wrote:

> I've been writing some csh scripts with cygwin and
> encountering a lot of problems.  I will admit that I
> am just learning, but I copied the scripts directly
> from the book!  I checked out the FAQ, and I am
> wondering if the reason why the scripts are not
> working are that they are being interpreted by bash
> not tcsh.  Is this possible?  Here is an example.  My
> script is:
>
> #csh that gives system status
>
> set d = `date`
> echo "Today's date: $d[2-3] $d[6]"
> echo "Current time: $d[4]"
> echo Number of users: `who | wc -l`
> echo Current disk storage: ` du -s .`
>
> Here is the response:
>
> Today's date: [2-3] [6]
> Current time: [4]
> Number of users: 0
> Current disk storage: 7 .
>
> Originally, the . was a ~ but that wasn't working
> because for some reason cygwin wasn't recognizing it.
> Using the FAQ for advice, I replaced ~ with $HOME
> which caused problems because my home directory is
> /home/Christopher Spears, which confuses bash, so I
> used ..  Obviously, [2-3], [6], and [4] are not the
> answers I was looking for in my script.
>
> What irks my is that I did download tcsh!  Was there
> something else I should have downloaded if I want to
> write csh scripts?
>
> -Chris

How exactly did you invoke the script?  FYI, the following works for me
(starting from a bash prompt):

$ cat > test.csh
set d = `date`
echo "Today's date: $d[2-3] $d[6]"
echo "Current time: $d[4]"
echo Number of users: `who | wc -l`
echo Current disk storage: ` du -s .`
^D
$ tcsh test.csh
Today's date: Apr 8 2004
Current time: 15:13:36
Number of users: 0
Current disk storage: 1 .
$

Alternatively,

$ sed -i '1i#!/usr/bin/tcsh' test.csh
$ chmod a+x test.csh
$ ./test.csh
Today's date: Apr 8 2004
Current time: 15:23:11
Number of users: 0
Current disk storage: 1 .

HTH,
	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