detecting if program is running under X windows or not

Discussion in 'Perl' started by Paul Faulstich, Jan 8, 2004.

  1. 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




    if ($ENV{LLB_DEBUG_TRIGGERS} and ! $PERLDB) {
    my @cmd = ($EXECUTABLE_NAME, "-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;'
    Paul Faulstich, Jan 8, 2004
    #1
    1. Advertising

  2. Paul Faulstich

    Amy G Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    >
    > if ($ENV{LLB_DEBUG_TRIGGERS} and ! $PERLDB) {
    > my @cmd = ($EXECUTABLE_NAME, "-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, Jan 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hshdude
    Replies:
    12
    Views:
    1,050
    Dimitri Maziuk
    Nov 4, 2004
  2. bronby
    Replies:
    1
    Views:
    602
    Andrew Thompson
    Jul 15, 2005
  3. Brian
    Replies:
    2
    Views:
    2,817
    Brian
    Dec 27, 2004
  4. Dave

    Detecting a program is running.

    Dave, May 25, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    101
  5. Stefan Ram
    Replies:
    5
    Views:
    150
    Stefan Ram
    Mar 17, 2014
Loading...

Share This Page