Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 avoiding work at the Monastery: (10)
As of 2015-07-02 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (33 votes), past polls