469,916 Members | 2,454 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,916 developers. It's quick & easy.

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
pf********@llbean.com

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;'
Jul 19 '05 #1
1 2208
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" <pf********@llbean.com> wrote in message
news:c9**************************@posting.google.c om...
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
pf********@llbean.com

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

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Woojay Jeon | last post: by
7 posts views Thread by fox | last post: by
3 posts views Thread by Chad Smith | last post: by
4 posts views Thread by Schroeder, AJ | last post: by
4 posts views Thread by Devraj | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.