[gradsusr] get output from shell command
Charles Seman
Charles.Seman at noaa.gov
Thu Mar 17 13:02:51 EDT 2011
Bernd,
I'm not sure how GrADS runs in parallel?
Do you start GrADS 17 different times? If so, if this would help,
perhaps you could give each of the "sysdate.dat" files a name using the
GrADS process ID's as follows (to illustrate technique):
ga-> echo `ps |grep grads`
Unknown command: echo
ga-> ! echo `ps |grep grads`
19846 pts/3 00:00:00 grads
ga-> ! echo `ps |grep grads | cut -f1`
19846 pts/3 00:00:00 grads
ga-> ! echo `ps |grep grads | cut -f1 -d' '`
19846
...after quiting GrADS and restarting:
ga-> !touch sysdate.`ps |grep grads | cut -f1 -d' '`
ga-> !ls sysdate.*
sysdate.19919
Note, you may need to do additional "bookkeeping" to know which
"sysdate.*" file to use when...
If the above does not seem workable, another possibility would be to
"append" the information to a single "sysdate.dat" file using ">>":
'!date >> sysdate.dat'
Note, you may need to initialize "sysdate.dat" like:
'!touch sysdate.dat'
before doing the first "append" using ">>"...
Then, keep track of which line in the file corresponds to which of the
17 GrADS shells... I'm not sure how you are initiating 17 GrADS shells,
or whether it is possible to know the order of how the GrADS shells are
started and/or the order in which each GrADS shell writes the "date"
into the "sysdate.dat" file, etc...
Hope this helps,
Chuck
Becker, Bernd 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.
>
> 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 Charles Seman
> Sent: 16 March 2011 18:15
> To: GrADS Users Forum
> Subject: Re: [gradsusr] get output from shell command
>
> Bernd,
>
> Arindam Chakraborty sent a technique to the Listserv (email exchange
> attached):
>
> '!date > sysdate.dat'
> d = read('sysdate.dat')
> d1 = sublin(d,2)
> say d1
>
>
>
> Hope this helps,
> Chuck
>
> 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
>>
>>
>
>
--
Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.
********************************************************************
Charles Seman Charles.Seman at noaa.gov
U.S. Department of Commerce / NOAA / OAR
Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547
201 Forrestal Road fax: (609) 987-5063
Princeton, NJ 08540-6649 http://www.gfdl.noaa.gov/~cjs/
********************************************************************
"The contents of this message are mine personally and do not reflect any
official or unofficial position of the United States Federal Government,
the United States Department of Commerce, or NOAA."
More information about the gradsusr
mailing list