in reply to How to know whether user terminates system("$cmd|more") with q or not?
Simply check the return value from system().
prints 0 on this 'ere system if I quit 'more' by hitting q, 2 if I quit by hitting control-C, 35072 if I kill-9 the 'more' process, and 36608 if I kill -15. The exact values returned may differ slightly from one implementation of 'more' to another, but you're probably safe if you assume that 0 means the user hit q and non-zero means that 'more' terminated for some other reason - just don't try to portably determine what that other reason was!$ perl -e 'print system("some thing|more")."\n"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to know whether user terminates system("$cmd|more") with q or not?
by BrowserUk (Patriarch) on Sep 14, 2011 at 09:40 UTC |