Perl and PHP do this with backticks. For example,
$output = `ls`;
Returns a directory listing. A similar function, system("foo")
, returns the operating system return code for the given command foo. I'm talking about a variant that returns whatever foo prints to stdout.
How do other languages do this? Is there a canonical name for this function? (I'm going with "backtick"; though maybe I could coin "syslurp".)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…