This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: writing csh scripts with cygwin


At 03:02 PM 4/8/2004, you 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?


No.  Your problem is exactly as you insinuated.  'bash'
is running your script because you didn't provide instructions
in the script for it to do otherwise.  Add "#!/bin/csh" as the
first line of your script.  Voila! ;-)


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]