[gradsusr] script similar to batch in Mac OS X

Rafanoharana Serge Claudio rafanoharana at gmail.com
Wed Sep 21 01:16:07 EDT 2011


Dear Arlindo,

Thank you for your answer. I have installed MacPort successfully but when I
try to sudo port install dos2unix, seems like can't connect to the server.
Then I saw that it was trying to download the expat 2.0.1.tar.gz so I
downloaded it manually and install. However when I run the dos2unix
run_script.bat, it says "dos2unix accept only standard input and output".

Serge

On Tue, Sep 20, 2011 at 9:19 PM, Arlindo da Silva <dasilva at alum.mit.edu>wrote:

> 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
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110921/d2647a3e/attachment-0003.html 


More information about the gradsusr mailing list