NRAO Home > CASA > CASA Cookbook and User Reference Manual

B.7.3 Shell Command and Capture

See also § B.9 for the use of the command history.

1. sx shell_command, !!shell_command - this captures the output to a list

  CASA [1]: sx pwd # stores output of ’pwd’ in a list  
    Out[1]: [’/home/basho3/jmcmulli/pretest’]  
 
  CASA [2]: !!pwd  # !! is a shortcut for ’sx’  
    Out[2]: [’/home/basho3/jmcmulli/pretest’]  
 
  CASA [3]: sx ls v* # stores output of ’pwd’ in a list  
    Out[3]:  
  [’vla_calplot.jpg’,  
   ’vla_calplot.png’,  
   ’vla_msplot_cals.jpg’,  
   ’vla_msplot_cals.png’,  
   ’vla_plotcal_bpass.jpg’,  
   ’vla_plotcal_bpass.png’,  
   ’vla_plotcal_fcal.jpg’,  
   ’vla_plotcal_fcal.png’,  
   ’vla_plotvis.jpg’,  
   ’vla_plotvis.png’]  
 
  CASA [4]: x=_ # remember ’_’ is a shortcut for the output from the last command  
 
  CASA [5]: x  
    Out[5]:  
  [’vla_calplot.jpg’,  
   ’vla_calplot.png’,  
   ’vla_msplot_cals.jpg’,  
   ’vla_msplot_cals.png’,  
   ’vla_plotcal_bpass.jpg’,  
   ’vla_plotcal_bpass.png’, ’vla_plotcal_fcal.jpg’,  
   ’vla_plotcal_fcal.png’,  
   ’vla_plotvis.jpg’,  
   ’vla_plotvis.png’]  
 
  CASA [6]: y=Out[2] # or just refer to the enumerated output  
 
  CASA [7]: y  
    Out[7]: [’/home/basho3/jmcmulli/pretest’]

2. sc - captures the output to a variable; options are ’-l’ and ’-v’

  CASA [1]: sc x=pwd # capture output from ’pwd’ to the variable ’x’  
 
  CASA [2]: x  
    Out[2]: ’/home/basho3/jmcmulli/pretest’  
 
  CASA [3]: sc -l x=pwd # capture the output from ’pwd’ to the variable ’x’ but  
                        # split newlines into a list (similar to sx command)  
 
  CASA [4]: x  
    Out[4]: [’/home/basho3/jmcmulli/pretest’]  
 
  CASA [5]: sc -v x=pwd # capture output from ’pwd’ to a variable ’x’ and  
                        # show what you get (verbose mode)  
  x ==  
  ’/home/basho3/jmcmulli/pretest’  
 
  CASA [6]: x  
    Out[6]: ’/home/basho3/jmcmulli/pretest’


More information about CASA may be found at the CASA web page

Copyright © 2010 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search