On 2021-11-22 17:07, Takashi Yano via Cygwin wrote:
On Mon, 22 Nov 2021 14:15:32 -0500
Dennis Putnam wrote:
I have a remote X application on a Linux system that I want to launch
with a Windows bat file. My main problem is how to determine if Cygwin/X
is running and if not launch it. Once verified I think all I need to do
is use SSH -Y with the command that starts the X application. Can
someone help? TIA.

What about something like:

set DISPLAY=:0
for /f "usebackq delims=" %%A in (`tasklist ^|find /C "XWin"`) do if %%A==0 
start C:\cygwin64\bin\XWin %DISPLAY% -multiwindow
c:\cygwin64\bin\ssh -Y 192.168.0.133 xterm

Note that the above bat fails to start XWin if it is already
started with DISPLAY other than :0.

Assuming Cygwin bin is in your PATH, check for xinit base process using one of the following commands:

$ tasklist /fi "imagename eq xinit.exe"               \
Image Name                   PID Session Name      Session#    Mem Usage
======================== ======= =============== ========== ============
xinit.exe                   2652 Console                  1      2,952 K
$ ps -aeW                                       \
   37738  37632  37632      2652 cons0    197609   Oct 21 /usr/bin/xinit
$ procps -C xinit                               \
  PID TTY          TIME CMD
37738 cons0    00:00:00 xinit

for first two commands, add check for xinit running:

| fgrep -w xinit \

and in all cases, if not, add X start, and sleep 60 or so, to give the X server adequate time, before starting the remote client:

|| (run --quote /usr/bin/bash -l -c "cd; exec /usr/bin/startxwin"; sleep 60;)

$ ssh -Y $REMOTE $CLIENT

If you want to find the display, try looking under /tmp/:

$ ll -go /tmp/.X*
-r--r--r--  1 11 Oct 21 09:56 /tmp/.X0-lock

/tmp/.X11-unix:
total 1.0K
srw-rw-rw- 1 0 Oct 21 09:56 X0=
-rw------- 1 0 Aug 18 10:31 X0.lock

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to