is there a more elegant way to achieve the following on windows?
perl -e "$|=1;for(1..100) { sleep 1; warn time; print time,qq{\n} }" 2>&1 | perl -ne "$|=1;print"
This first script is printing time every second to STDOUT and STDERR.
If the output is connected to a Windows cmd.exe and any text was selected with the mouse, than the output will not only stop but the script will freeze and only continue after the selection was finished!
D:>perl -e "$|=1;for(1..100) { sleep 1; warn time; print time,qq{\n} +}" 1530361604 at -e line 1. 1530361604 1530361605 at -e line 1. 1530361605 # selecting text for some se +conds 1530361606 at -e line 1. # output resumes,last buffer +ed line 1530361622 # after freeze 1530361623 at -e line 1. 1530361623 1530361624 at -e line 1. 1530361624 1530361625 at -e line 1. 1530361625 Terminating on signal SIGINT(2)
( update for clarity: my problems is not that the output stops, but that the complete script stops running in the background.)
The behaviour in a linux terminal is different (much saner), the output might stop but the script will continue running in the background and the buffered output will appear after the selection.
My workaround is now piping the STDOUT and STDERR to a second Perl script which does the buffering without blocking the main script, but is not overly elegant...
Background information is that our provider changed the windows version and activated "QuickEdit mode" for consoles on default.
Now my colleagues are surprised to find out that their batch jobs freeze whenever someone does a simple click into a window which will "quickly" cause a selection ...
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
PS: I'd rather prefer running the scripts with wperl and directing STDOUT and STDERR to a file. If a live display is needed I'd use a tail -f approach, like with powershells get-content File -wait . Alas changing old working patterns in a team isn't easy ...
PPS: deactivating quickEdit in the registry (which isn't trivial for political reasons) doesn't solve the underlying issue, since a text selection could be initiated anyway.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |