*! version 1.0 05February2009 program def ashell, rclass version 8.0 syntax anything (name=cmd) /* This little program immitates perl's backticks. Author: Nikos Askitas Date: 04 April 2007 Modified and tested to run on windows. Date: 05 February 2009 */ * Run program display `"We will run command: `cmd'"' display "We will capture the standard output of this command into" display "string variables r(o1),r(o2),...,r(os) where s = r(no)." local stamp = string(uniform()) local stamp = reverse("`stamp'") local stamp = regexr("`stamp'","\.",".tmp") local fname = "`stamp'" shell `cmd' >> `fname' tempname fh local linenum =0 file open `fh' using "`fname'", read file read `fh' line while r(eof)==0 { local linenum = `linenum' + 1 scalar count = `linenum' return local o`linenum' = `"`line'"' return local no = `linenum' file read `fh' line } file close `fh' if("$S_OS"=="Windows"){ shell del `fname' } else{ shell rm `fname' } end