Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to know whether user terminates system("$cmd|more") with q or not?

by DrHyde (Prior)
on Sep 14, 2011 at 09:29 UTC ( #925847=note: print w/ replies, xml ) Need Help??


in reply to How to know whether user terminates system("$cmd|more") with q or not?

Simply check the return value from system().

$ perl -e 'print system("some thing|more")."\n"'
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!


Comment on Re: How to know whether user terminates system("$cmd|more") with q or not?
Download Code
Re^2: How to know whether user terminates system("$cmd|more") with q or not?
by BrowserUk (Pope) on Sep 14, 2011 at 09:40 UTC
    0 means the user hit q and non-zero means that 'more' terminated for some other reason

    What value do you get if the user allows more to terminate on eof?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-09-17 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (55 votes), past polls