All Forums |
Register |
Login |
Search |
Subscriptions |
My Profile |
Inbox |
Tool Warehouse |
FAQs |
Resources |
Help |
Member List |
Address Book |
Logout |
|
|
Running applications on the glass remotely
|
Logged in as: Guest |
Users viewing this topic: none |
|
Login |
|
|
Running applications on the glass remotely - Sep. 22, '04, 12:12:23 PM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Carrying on from discussions a while a go here:
http://www.interopsystems.com/tools/forum/tm.asp?m=1521&mpage=2&key=glass
I've finally got round to looking at this again.
Using:
posix /c c:/windows/system32/notepad.exe
I can get notepad to run from:
1. A local csh session ( displays )
2. A remote ssh session ( doesnt display ).
3. A apache cgi session ( doesnt display ).
The issue is the although it is running in 2 and 3 its not displaying on the glass even when apache was started from the local csh session. markfunk mentioned in the above thread ( 3 posts from the end ) that:
quote:
It may be possible to run install apache as a Windows service, running at local Administrator, and then click the "interact with desktop" button.
At this point, the psxrun.exe that runs may have sufficient privileges that will allow the Win32 gui app to access the windows station.
I don't know for sure, just a guess.
So the question is whats the best way to install an interix process as a windows service?
< Message edited by steveh -- Sep. 22, '04, 1:00:03 PM >
|
|
|
RE: Running applications on the glass remotely - Sep. 22, '04, 5:23:04 PM
|
|
|
cortez_
Posts: 330
Joined: Mar. 27, '04,
From: Poland
Status: offline
|
You might want to try to use the Firedeamon utility, although I did not succed yet with this. Another way ti to try to look into the man service
|
|
|
RE: Running applications on the glass remotely - Sep. 22, '04, 7:49:05 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
WRT to Mark's suggestion quoted.
As I recall the code there was a specific option that was used to create a separate
window station for each pty for security reasons. But I can't remember if we did do
it or it was intended. A while ago now.
You would need to have the process needing to be a service no do the "daemon" thing
of fork'ing with the parent exiting. That way the service manager won't complain that
the service died.
|
|
|
RE: Running applications on the glass remotely - Sep. 22, '04, 7:50:24 PM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Ok making a bit of progress.
If I use svrany to create a service with:
Application=c:\sfu\usr\local\bin\perl
AppParameters=-w /var/tmp/test.pl
and said script contains:
#!/usr/local/bin/perl -w
use strict;
{
my $pid = fork();
if ( ! defined $pid )
{
print "Can't fork: $!", 2;
exit 1;
}
if ( $pid )
{
# Parent
print qq{Parent waiting for $pid\n};
wait;
print qq{Parent done\n};
}
else
{
# Child
print qq{Child stating notepad\n};
system( '/dev/fs/C/WINDOWS/system32/notepad.exe' );
print qq{Child done\n};
}
exit 0;
}
The service starts and notepad is displayed exactly what I need.
However if I take it to the next level and use apache as my base level service and then exec the script via cgi. The notepad is started but its not displayed. I though this may be because apache was daemonizing so I added -F to the command line so I now have:
Application=c:\sfu\usr\local\apache\bin\httpd
AppParameters=-F
AppEnvironment=LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib:/usr/local/lib
Apache fails with:
setsid: Operation not permitted
httpd: setsid failed
setsid() failed probably because you aren't running under a
process management tool like daemontools
Even when started from the command line it does the same.
Will did around in the apache code to see if thats something that can be fixed tomorrow.
< Message edited by steveh -- Sep. 22, '04, 7:52:03 PM >
|
|
|
RE: Running applications on the glass remotely - Sep. 22, '04, 8:20:51 PM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
So close I can taste it now. After comenting out the setsid section of apache -F works. However I still dont get notepad displayed when apache is started via the service. If however I start if from a csh session on the glass all is good. So what am I missing ?
1. Perl script direct from the service works.
2. Perl script via Apache started in csh on the glass works.
3. Perl script via Apache started from the service doesnt :(
|
|
|
RE: Running applications on the glass remotely - Sep. 22, '04, 8:35:07 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
The services are started in their own window station.
Did you try checking the box Mark suggested?
|
|
|
RE: Running applications on the glass remotely - Sep. 23, '04, 3:33:39 AM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Yer thats how I got it working with cygwin and how the Perl script direct from the service works. Seems apache is doing something when run via interix which it didnt do under cygwin.
One silly option I thought of was to start a shell from the service instead and then fire off apache from there but I cant figure out how to perswade csh to start a full window and then fire off a command.
/bin/csh -c "......" doesnt seem to work the command just exits.
|
|
|
RE: Running applications on the glass remotely - Sep. 23, '04, 8:51:12 AM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
Then things are as I remember. It is running in a separate window station.
|
|
|
RE: Running applications on the glass remotely - Sep. 23, '04, 9:21:00 AM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Ok a bit more using the following perl script as the shell:
#!/usr/local/bin/perl -w
use strict;
print qq{Starting apache\n};
system( '/usr/local/apache/bin/httpd -F -d /usr/mydir -f /usr/mydir/myhttpd.conf' );
print qq{Apache done\n};
exit 0;
With:
Application=c:\sfu\usr\local\bin\perl
AppParameters=-w /var/tmp/test.pl
It all works. But firing apache directly apache just quits. Im slowly working through the apache source looking for where and why it exists but this is extreamly painful ( adding a sleep statement to see where its exists as I cant trap the output ). Any pointers?
|
|
|
RE: Running applications on the glass remotely - Sep. 23, '04, 10:01:00 AM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Well I found the problem but I dont understand it.
src/main/http_main.c:
if (freopen("/dev/null", "w", stdout) == NULL) {
fprintf(stderr, "%s: unable to replace stdout with /dev/null: %s\n",
ap_server_argv0, strerror(errno));
}
As soon as this runs this server exits. I dont understand why this would ever make the app exit and then only when run from a service. Any ideas?
< Message edited by steveh -- Sep. 23, '04, 10:01:21 AM >
|
|
|
RE: Running applications on the glass remotely - Sep. 23, '04, 10:53:48 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
Yeah, stdout right now connects to a Win32 stdout because it was started through the service manager.
(that's my best reasoning).
|
|
|
RE: Running applications on the glass remotely - Sep. 24, '04, 6:46:02 AM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
So safe to just #ifndef _INTERIX_SERVICE_FIX it out then? Thanks for all the pointers guys looks like I've got this working. The only improvement is if I could get it to hide the window while still allowing access to the glass as I dont want someone accidently closing the window.
Is there some code I could add into the apache to achieve this?
Also do you have a patchset you apply to the default apache install so that I can update to the latest version. The current tools version is out of date as it stands .29 vs .31 ( security patches ). Would be cool if we could get these added to the default apache download so it all works out the box as it where.
|
|
|
RE: Running applications on the glass remotely - Sep. 26, '04, 7:04:00 PM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Next on the hit list is screen. From csh session under rdp I can run notepad and it all displays nicely however if I run screen first I get:
$ notepad
ERROR: /dev/fs/C/WINDOWS/system32/notepad.exe will not run. No access to the displayable Windows station.
(eg) Win32 GUI apps won't run in a telnet session.
Any pointers on where to look in screen which is loosing the access to the window station?
|
|
|
RE: Running applications on the glass remotely - Sep. 26, '04, 8:15:32 PM
|
|
|
jonsmi
Posts: 168
Joined: Aug. 12, '03,
From: Oslo, Norway
Status: offline
|
quote:
Next on the hit list is screen. From csh session under rdp I can run notepad and it all displays nicely
Fine, this is due to Terminal Services, Terminal Server, Remote Desktop -- in short the
names have changed, but the technology is basically the same. If you're interested in
a in-depth view:
"Inside Microsoft Terminal Server", by Mark Russinovich, one of the most re-known
Windows Internals gurus.
http://www.winntmag.com/Articles/Index.cfm?IssueID=54&ArticleID=3594
quote:
however if I run screen first I get:
$ notepad
ERROR: /dev/fs/C/WINDOWS/system32/notepad.exe will not run. No access to the displayable Windows station. (eg) Win32 GUI apps won't run in a telnet session.
This is by design. Windows is originally conceived as a multiuser system with one --
and only one -- interactive user. The technology behind Terminal Server changed this,
but requires a special protocol, either RDP or ICA.
quote:
Any pointers on where to look in screen which is loosing the access to the window station?
I know of none, you'll always need a window station. There are to types:
(1) interactive (Notepad needs this) and this station contains desktops and desktops contain windows. Only one window station can be visible on a console and receive user mouse and keyboard input.
(2) The Service Control Manager associates services with a non-visible window station that all non-interactive services share.
So what more is the problem? Oh, one more thing, interactive Win32 consoles won't work,
such as the non-graphical vim for Windows. But you can run a lot of the new console
utilities to manage DNS, DHCP, AD, etc. in Windows 2003. Best practices is to
edit/create scripts in /usr/contrib/win32/bin on the remote machine.
Jon-Alfred Smith
MCSE+I, MCSA, MCDBA, CCNA
|
|
|
RE: Running applications on the glass remotely - Sep. 26, '04, 8:26:47 PM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Think you got the wrong end of the stick there Jon.
screen is a unix utility and has nothing to do with rdp / terminal services etc.
This issue is: something that screen is or isn't doing in its initialisation is preventing applications starting on the window station that run correctly from the source csh session.
I'm looking for pointers on what may be causing this so I can fix it :P
|
|
|
RE: Running applications on the glass remotely - Sep. 26, '04, 8:53:07 PM
|
|
|
jonsmi
Posts: 168
Joined: Aug. 12, '03,
From: Oslo, Norway
Status: offline
|
quote:
ERROR: /dev/fs/C/WINDOWS/system32/notepad.exe will not run. No access to the displayable Windows station. (eg) Win32 GUI apps won't run in a telnet session.
Sorry, then I don't get what you mean. You were talking about RDP, and then I
understood it as you were telneting into a remote machine. I did the same, with
the same error message:
jonsmi@ayla:~> ssh felicia
jonsmi@felicia's password:
Welcome to the Interix UNIX utilities.
DISPLAY=localhost:0.0
jonsmi@felicia:~> notepad
ERROR: /dev/fs/C/WINDOWS/system32/notepad.exe will not run. No access to the
displayable Windows station. (eg) Win32 GUI apps won't run in a telnet session.
jonsmi@felicia:~> logout
Connection to felicia closed.
jonsmi@ayla:~>
What is this screen utility? Where do I get hold on that for Interix, and what does
it do for a living?
|
|
|
RE: Running applications on the glass remotely - Sep. 27, '04, 7:47:51 AM
|
|
|
steveh
Posts: 195
Joined: Jan. 23, '04,
Status: offline
|
Screen is a gnu utility that enableds you to run things, disconnect and then switch back to them.
Its great for monitoring long runing operations or as we use it to check console ouputs. Its a gun utility and can be grabbed from any gnu mirror. Once you have it search the form's for mark's / rodney's tips on getting it to compile.
< Message edited by steveh -- Sep. 27, '04, 7:48:22 AM >
|
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
|
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts |
|
|
|