473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2263
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Woojay Jeon | last post by:
OK, I tried a Google search on this Usenet group but couldn't find a solution, so I'm posting my question here (if there's a better archive than the one in Google, please let me know). Does...
7
by: Joecx | last post by:
Hi Does anyone have the code or maybe give me a start on how to detect if my program is already running if someone tries to run it again while it's already running? I know I could do this with a...
7
by: fox | last post by:
Maybe this is not the best group to ask this question, but I don't know a better one. I'm looking for a *portable* program in C (I mean source code) to detect whether unaligned word access is:...
3
by: steve | last post by:
Hi All I need to write a program to read input from barcode scanner. The program is for a gym and needs to detect when a card is scanned regardless of which program is currently running ont he...
3
by: Chad Smith | last post by:
Hi, I have created a .NET deployment project in Visual Studio 2003. I have specified an entry point into my own code in this installer which launches into the familiar: public override void...
4
by: Schroeder, AJ | last post by:
Hello group, I have a few PHP scripts that poll switches and routers via SNMP. Depending on the user, the scripts can be run from either Windows XP or *ix (FreeBSD, Redhat, etc) I am...
1
by: Steve | last post by:
Hi All I have a windows application (written in VB.net 2005) which I update via web downloads to my clients computers The downloaded file is saved in a subfolder until the next time the...
4
by: Devraj | last post by:
Hi everyone, My Python program needs reliably detect which Operating System its being run on, infact it even needs to know which distribution of say Linux its running on. The reason being its a...
2
AaronL
by: AaronL | last post by:
Hello, Is there an API I can use to detect windows processes? For example, if I were to run notepad.exe, and I wanted to pop a message up in my program that said "notepad.exe" is running? How...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.