LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Trying to kill a Firefox window through remote ssh session (https://www.linuxquestions.org/questions/linux-software-2/trying-to-kill-a-firefox-window-through-remote-ssh-session-4175413274/)

JimiSc 06-25-2012 09:37 AM

Trying to kill a Firefox window through remote ssh session
 
Hello,

I am lost as to what command I can use to kill a Firefox window through a remote ssh session. I have a Linux machine running openSuse 12.1 that I use here at work for our lobby t.v. I have crontab set to open Firefox first thing in the morning and when it does that Firefox, due to the web address that it is pointed too, opens a total of three windows, only two of which i actually need displayed. So my question is what terminal command can I use to kill the one window I do not need? I would like to be able to eventually add the command to the .sh script I wrote to open Firefox.

Thanks in advance for the help

Jimi

unSpawn 06-25-2012 10:41 AM

Quote:

Originally Posted by JimiSc (Post 4711315)
Firefox, due to the web address that it is pointed too, opens a total of three windows

So what's wrong with the address? Does it use something like "target="blank"" to open several windows?

JimiSc 06-25-2012 11:31 AM

unSpawn,

No it does not return anything like that. After reading my post I realized I did not explain that very clearly. Firefox's home page is set to an internal web address http://xxx.xxxxx.xxx/xxx/luanch.php (sorry for security reasons cant give the whole address), from there it opens two additional windows that have the actual info that I want displayed, conference schedules, contact info and so on. The original window just stays a blank grey screen that to be honest is doing nothing and for cleanliness I would like to be able to close it and just have the two windows open that are needed. I remote into this box using PuTTY so I would like to be able to do this through the terminal.

pan64 06-25-2012 12:10 PM

I think the way is to identify the window (by title) and send a close command. You can try wmctrl to implement it.

JimiSc 06-25-2012 12:49 PM

Quote:

Originally Posted by pan64 (Post 4711474)
I think the way is to identify the window (by title) and send a close command. You can try wmctrl so implement it.

I have installed this program and when I try to use it all I get is 'Cannot open display' I have tried using wmctrl -F -c <window name> as well as /usr/bin/wmctrl -F -c <window name>, both give me the same message Cannot open display.

pan64 06-25-2012 12:54 PM

that means you do not have access right to that DISPLAY. In this case there is no way to identify the window, there is no way to send events to that window manager, you can only kill the process (firefox) itself. You need to give access right to that user...

JimiSc 06-25-2012 01:02 PM

I see.....that would make sense. Ok so then how would I go about giving access to it through an ssh session? Still pretty new to Linux.

JimiSc 06-25-2012 01:59 PM

Quote:

Originally Posted by pan64 (Post 4711474)
I think the way is to identify the window (by title) and send a close command. You can try wmctrl so implement it.

Thank you for letting me know about this command. I was finally able to get it to work and close out the window I wanted it to close. I forgot that since I was running this command remotely that I had to first tell it what display it was, Adding DISPLAY=:0 to the beginning of the command made it work with no further issues. Thanks again

pan64 06-26-2012 01:12 AM

Quote:

Originally Posted by JimiSc (Post 4711520)
Ok so then how would I go about giving access to it through an ssh session? Still pretty new to Linux.

This is not possible in general. You cannot give yourself access rights to another display, the owner of that display can give you access with the command xhost. In your case the user was the same and therefore you did not need to set additional rights but the DISPLAY variable. ssh does not know about that session.


All times are GMT -5. The time now is 03:16 PM.