[gradsusr] get output from shell command

Becker, Bernd bernd.becker at metoffice.gov.uk
Thu Mar 17 05:23:58 EDT 2011


 
Lee,

this will work well if one writes the ctl file from the unix shell. 

I write the ctl file from within grads and it matters. 

Many thanks,
Bernd.



--
Bernd Becker   Climate Impacts Product Development
Met Office Hadley Centre    FitzRoy Road  Exeter   Devon EX1 3PB  United
Kingdom
Tel.: +44 (0) 1392 884511 Fax: +44 (0)870 900 5050
E-mail:bernd.becker at metoffice.gov.uk -
http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/
bernd-becker


-----Original Message-----
From: gradsusr-bounces at gradsusr.org
[mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Lee Byerle
Sent: 17 March 2011 01:45
To: GrADS Users Forum
Subject: Re: [gradsusr] get output from shell command

Hi Bernd,
How about use of substitutions to get "date" into grads script starting
from a template grads script:

For example:

set yrg = ` date  +%y `
set mng = ` date  +%m `
set dyg = ` date  +%d `


sed "s/DATEVAL/20${yrg}${mng}${dyg}/g" template_script.gs >   
newscript.gs

Lee


On Mar 16, 2011, at 10:32 AM, Becker, Bernd wrote:

>
> Hello,
>
> how do I get the output from shell command "date"
> into the grads shell?
>
> '!date'
> res  = result
> say rc    res
> res=sublin(rc,2)
> say rc    res
> say subwrd(res   ,2)
>
> doesn't do it.
>
> Te following does, but with caveats:
> I got this far:
>
> '!date -d 'fxdate' +%b > ./erp2'
> record2=read('./erp2')
> mon=sublin(record2,2)
>
> but it is unsave if multiple processes run in parallel and overwrite 
> erp2. Not good enough.
>
> many thanks!
>
> Bernd.
>
> --
> Bernd Becker   Climate Impacts Product Development
> Met Office Hadley Centre    FitzRoy Road  Exeter   Devon EX1 3PB   
> United
> Kingdom
> Tel.: +44 (0) 1392 884511 Fax: +44 (0)870 900 5050 
> E-mail:bernd.becker at metoffice.gov.uk - 
> http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decada
> l/
> bernd-becker
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr




More information about the gradsusr mailing list