let old_stdout = stdout
rd, = redirect_stdout()
try
println("This output is redirected.\n")
finally
redirect_stdout(old_stdout) # restore original stdout
end
output = String(readavailable(rd))
println("captured the output: ", output)
end
3 Likes