[gradsusr] get output from shell command

Becker, Bernd bernd.becker at metoffice.gov.uk
Fri Mar 18 11:02:18 EDT 2011


Thank you , Arlindo!
 
The "@" to expand the shell environment variables is exactly what cures 
my problem.
 
I needed to tag temporary files to run grads scripts in parallel. 
Tagging these files with the current $$ is a viable solution.
 
I want to use the mighty power of shell command date to reformat 
current date settings inside grads.
 
fxdate is some date in yyyymmdd. To write the tdef flag in a temporary
grads.ctl file,
the 3 character date is required:
 
* Arlindo's suggestion
'@ !/opt/freeware/bin/date -d 'fxdate' +%b > ./erp2$$'
filename = subwrd(result,6)
 
record2=read(filename)
mon=sublin(record2,2)
 
and hey presto, mon holds the 3 character month from fxdate. 
 
Many thanks,
enjoy the weekend.
 
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



 

________________________________

From: gradsusr-bounces at gradsusr.org
[mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Arlindo da Silva
Sent: 18 March 2011 00:41
To: GrADS Users Forum
Subject: Re: [gradsusr] get output from shell command


On Thu, Mar 17, 2011 at 5:20 AM, Becker, Bernd
<bernd.becker at metoffice.gov.uk> wrote:




	Chuck,
	nice solution,
	but if you have 17 grads shells running in parallel, eventually
	one of them may overwrite sysdate.dat and that would be bad.
	



If you are using an opengrads release you can use the environment
expansion capability, and the the process ID variable $$, to create
unique (per grads instance) temporay files. For this particular example,
try:


'@ !date > sysdate.dat.$$'
filename = subwrd(result,3)
 d = read(filename)
 d1 = sublin(d,2)
 say d1



The Env extension adds a lot of convenient environment variable
functionality to GrADS. See this for more information:

        http://opengrads.org/doc/udxt/env/

   Arlindo

-- 
Arlindo da Silva
dasilva at alum.mit.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110318/ccf0998e/attachment-0003.html 


More information about the gradsusr mailing list