Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
The stupid question is the question not asked
 
PerlMonks  

Re: How to detect X?

by Zaxo (Archbishop)
on Feb 21, 2005 at 03:58 UTC ( [id://432978]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to How to detect X?

You could simply try the X version first. If the X server fails to appear, exec returns with an error -- the only way exec can return. Then try the command-line version.

exec "$bin/$name.X", @args; exec "$bin/$name.cmd", @args;

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: How to detect X?
by blazar (Canon) on Feb 21, 2005 at 04:39 UTC
    You could simply try the X version first. If the X server fails to appear, exec returns with an error -- the only way exec can return. Then try the command-line version.
    This is fundamentally what I had thought of doing myself, even though, really I was rather thinking of putting some minimal Tk code in an eval block instead. Yes: I know that basically that would mean doing the same thing twice, but it seems somewhat cleaner... of course unless there's an even cleaner solution.
Re^2: How to detect X?
by Anonymous Monk on Feb 21, 2005 at 05:10 UTC
    No, that doesn't work. From the manual page:
    It [exec] fails and returns false only if the command does not exist and it is executed directly instead of via your system's command shell (see below).
    Since in this case "$bin/$name.X" must exist, the exec will succeed. The fact that "$bin/$name.X" can't do its job doesn't mean the exec will magically resurrect the program.

    In fact, if you turn warnings on, the lines you give above will generate a warning:

    Since it's a common mistake to use "exec" instead of "system", Perl warns you if there is a following statement which isn't "die", "warn", or "exit" (if "-w" is set - but you always do that).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://432978]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.