473,549 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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********@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;'
Jul 19 '05 #1
1 2268
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********@llb ean.com> wrote in message
news:c9******** *************** ***@posting.goo gle.com...
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********@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;'

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4347
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 anybody know how to detect the operating system under which the current Python program is running, especially whether it's Windows or Unix? I have a...
7
6101
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 dummy file by putting something in the file while it's running and emptying the file when it's not running, but I was hoping for something a little...
7
2336
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: a. handled by the main processor (e.g. x86) b. not supported (e.g. Sparc running Solaris) c. emulated in software (e.g. Alpha running Linux) By...
3
10664
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 computer. e.g the operator might be typing a letter and a member swipes his card. I am convinced I need to write the card reader section as a...
3
4015
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 Install(IDictionary savedState) { Application.Run(new MyForm()); base.Install(savedState);
4
1363
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 beginning to implement syslog() and openlog() in my scripts and there are some suddle differences in how PHP logs to event viewer in Windows and syslog in...
1
2191
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 clients computer is started An entry in the registry HKCU\Software\Microsoft\Windows\CurrentVersion\Run launches my Update program on the next windows...
4
4539
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 GTK application that needs to adapt itself to be a Hildon application if run on devices like the N800. I have been searching around for an answer...
2
2841
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 would I do that? The real reason I want to do this is because I don't want my program interrupting me if certain programs are running, so if media...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7956
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.