bash - Console output suppressed. Why? -
in bash script have function that:
- contains
expectscript spawning ssh connection remote device - and depending on whether connection timed-out or not
echo's string effect (as return value)
when run script terminal , bash script reaches statement of:
myexpectfunc [further code...] why can see console output of expect script, if following:
retval=$(myexpectfunc) [further code...] there no console output? suppressed until retval has been assigned value.
i'd keep local variables functions , return values of these variables return value me able case on. of course if don't declare local variables function variable global , can case on global variable. i'd rather not this. there way able maintain console output , assign return value retval?
so there way able maintain console output , assign return value retval?
yes. use tee:
retval=$(myexpectfunc | tee /dev/tty) all of standard output myexpectfunc sent standard input of tee. tee copies both file /dev/tty (which terminal) , own standard out (which captured retval).
Comments
Post a Comment