[gradsusr] script similar to batch in Mac OS X

Arlindo da Silva dasilva at alum.mit.edu
Tue Sep 20 10:19:50 EDT 2011


On Tue, Sep 20, 2011 at 8:55 AM, Rafanoharana Serge Claudio <
rafanoharana at gmail.com> wrote:

> Dear all,
>
> I guess that it is not the right place to ask this question, but I know
> that it can be solved here that's why I'm asking...
> In Windows, in order to make a time series data, I use .bat file which name
> is run_script.bat and which contains:
>
> foreach m (1 2 3 4 5 6 7 8 9 10 11 12)
> ncdump fpar_re_2001_$(m).nc > test.cdl
> sed -n '1,1p' test.cdl > test1.cdl
> cat header_fpar_re_2001.txt >> test1.cdl
> echo "" >> test1.cdl
> echo "data:" >> test1.cdl
> echo "" >> test1.cdl
> echo " time = $(m) ; " >> test1.cdl
> echo "" >> test1.cdl
> sed -n '16,20000000p' test.cdl >> test1.cdl
> ncgen -o fpar_re_fnl_2001_$(m).nc test1.cdl
> end
>
> and I use command prompt to run it:
>
> tcsh run_script.bat
>
> and it works perfectly.
>
>
> Now, I move to Mac OS X and try to run this script. I did:
>
> csh run_script.bat
>
> but always get an error: "foreach: Words not parenthesized."
> I have already changed the $(m) to ${m} and even type directly the name of
> the file but always obtain the message "foreach: Words not parenthesized."
> I changed the extension to .sh but always the same problem.
>
>
Even though you have .bat in your script file name, from the above it is
clear that you are running a c-shell script, an old habit of mine as well.
 The issue you are having on Mac OS X is most likely because your
"run_script.bat" file was created on Windows and has the funny MS-DOS line
ending characters. All you need to do is to run this utility on your file:

% dos2unix run_script.bat

Here is the catch: if dos2unix is not standard on Mac OS X. If it is not
available in your system you can install it from macports with

% sudo port install dos2unix

If you don't have macports installed, see here: http://www.macports.org/ or
ask your sys admin to install it for you. (It is possible that I included
some version of dos2unix with the opengrads win32 superpack, I can't
remember.)

  Arlindo



> Any help would be very helpful.
>
> Thank you,
>
> Serge
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Arlindo da Silva
dasilva at alum.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110920/df324844/attachment-0003.html 


More information about the gradsusr mailing list