detecting if program is running under X windows or not

P

Paul Faulstich

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
(e-mail address removed)



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;'
 
A

Amy G

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top