detecting if program is running under X windows or not

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Faulstich

    detecting if program is running under X windows or not

    I am writing a script that checks an environment variable and, if it
    is set, will re-run itself in debug mode.

    I have this working fine under win32 and unix when its launched from
    the command line, but if an X-windows program launches it, it doesn't
    know to first open up an xterm and run itself in that.

    How can I get perl to either
    - check to see if it was launched under X-windows, OR
    - attempt to launch the Xterm by default, and if it fails then try to
    run directly through the stdin/out

    For what its worth, the current code snippet below. Comments,
    derision, etc are welcomed.

    Thanks,

    Paul Faulstich
    pfaulstich@llbe an.com



    if ($ENV{LLB_DEBUG _TRIGGERS} and ! $PERLDB) {
    my @cmd = ($EXECUTABLE_NA ME, "-d", "-w", $PROGRAM_NAME, @ARGV);
    my @run;
    if (MSWIN) {
    @run = ("START", "/WAIT", join(" ", @cmd), @cmd);
    } else {
    # attempt to initiate an X-windows session. If this fails,
    then
    # attempt to run directly
    # gotta fill this in so it works from xwindows.
    @run = @cmd;

    }
    my $result = system (@run);
    exit $result;
    }

    obviously, MSWIN is defined outside of this and I 'use English;'
  • Amy G

    #2
    Re: detecting if program is running under X windows or not

    You may want to take a look at the man page for xterm. I think it is
    xterm -e <command [options]> that first opens xterm and then runs command
    with the options.


    "Paul Faulstich" <pfaulstich@llb ean.com> wrote in message
    news:c9c77658.0 401081217.4e28d ae9@posting.goo gle.com...[color=blue]
    > I am writing a script that checks an environment variable and, if it
    > is set, will re-run itself in debug mode.
    >
    > I have this working fine under win32 and unix when its launched from
    > the command line, but if an X-windows program launches it, it doesn't
    > know to first open up an xterm and run itself in that.
    >
    > How can I get perl to either
    > - check to see if it was launched under X-windows, OR
    > - attempt to launch the Xterm by default, and if it fails then try to
    > run directly through the stdin/out
    >
    > For what its worth, the current code snippet below. Comments,
    > derision, etc are welcomed.
    >
    > Thanks,
    >
    > Paul Faulstich
    > pfaulstich@llbe an.com
    >
    >
    >
    > if ($ENV{LLB_DEBUG _TRIGGERS} and ! $PERLDB) {
    > my @cmd = ($EXECUTABLE_NA ME, "-d", "-w", $PROGRAM_NAME, @ARGV);
    > my @run;
    > if (MSWIN) {
    > @run = ("START", "/WAIT", join(" ", @cmd), @cmd);
    > } else {
    > # attempt to initiate an X-windows session. If this fails,
    > then
    > # attempt to run directly
    > # gotta fill this in so it works from xwindows.
    > @run = @cmd;
    >
    > }
    > my $result = system (@run);
    > exit $result;
    > }
    >
    > obviously, MSWIN is defined outside of this and I 'use English;'[/color]


    Comment

    Working...