x404.co.uk
http://www.x404.co.uk/forum/

Adding option to command line
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=8633
Page 1 of 1

Author:  koli [ Thu Jun 03, 2010 8:16 am ]
Post subject:  Adding option to command line

I need to implement this (add -forever option) to my x11vnc under latest Ubuntu:
http://ubuntuforums.org/showpost.php?p= ... ostcount=5

I have set up x11vnc to run at the startup so I assume I need to modify the "exe" file for it. I just don't know how...

Author:  forquare1 [ Thu Jun 03, 2010 8:29 am ]
Post subject:  Re: Adding option to command line

How have you specified x11vnc to be run on startup? Can you not specify the flag then?

Modifying the binary file could be impossible, and even if it is possible it would be not be advisable (what happens when one day you don't want to use the flag?).

Author:  forquare1 [ Thu Jun 03, 2010 8:34 am ]
Post subject:  Re: Adding option to command line

I presume you did this:
Code:
sudo nano /etc/inetd.conf

And added this to that file:
Code:
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh


I would say you could probably do this:
Code:
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever


If that doesn't work, try quoting it with double quotes or back ticks like this:
Code:
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd `/usr/local/bin/x11vnc.sh -forever`

Code:
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd "/usr/local/bin/x11vnc.sh -forever"


Ben

Author:  koli [ Thu Jun 03, 2010 10:11 am ]
Post subject:  Re: Adding option to command line

I have set up start-up by going admin-sessions in the menus and added the x11vnc file to the list. I haven't done any command lines except for setting a password for vnc sessions.

Those command lines you have suggest seem very complicated. Do I need them all? Right now I need to add -forever and -password options (vnc is not asking for a password when I connect even though password was specified by a command line I have done).

I could probably do with -localhost option too so nobody from outside can connect to it. I am behind a firewall so port forwarding is better left out as well, just to be safe.

Author:  forquare1 [ Thu Jun 03, 2010 10:36 am ]
Post subject:  Re: Adding option to command line

I looked at this site here:
http://wiki.linuxquestions.org/wiki/X11vnc

koli wrote:
Those command lines you have suggest seem very complicated. Do I need them all? Right now I need to add -forever and -password options (vnc is not asking for a password when I connect even though password was specified by a command line I have done).

I could probably do with -localhost option too so nobody from outside can connect to it. I am behind a firewall so port forwarding is better left out as well, just to be safe.


I you would only need to do one of them, probably the following:
Code:
sudo nano /etc/inetd.conf
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever -localhost -password


I'm not sure of using the Linux service framework as Solaris works quite differently. But out of the reading I've done on from the link above, I think that's right...

Author:  koli [ Thu Jun 03, 2010 11:01 am ]
Post subject:  Re: Adding option to command line

Ok, I will run that in the console tonight and will report my findings. Thanks.

Author:  EddArmitage [ Thu Jun 03, 2010 2:56 pm ]
Post subject:  Re: Adding option to command line

Just a bit of explanation around Ben's advice, so you understand what you're doing. I'm not sure what the inetd.conf file is for, or what the line in the file means, but I guess Google will explain if you're curious/it doesn't work.
forquare1 wrote:
Code:
sudo nano /etc/inetd.conf
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever -localhost -password

sudo - Run as Super User (Super User DO)
nano - A text editor
/etc/inetd.conf - The file you want to edit

Then you just need to add or edit the second line into text file from within the nano editor.

Author:  forquare1 [ Thu Jun 03, 2010 3:05 pm ]
Post subject:  Re: Adding option to command line

EddArmitage wrote:
Just a bit of explanation around Ben's advice, so you understand what you're doing. I'm not sure what the inetd.conf file is for, or what the line in the file means, but I guess Google will explain if you're curious/it doesn't work.
forquare1 wrote:
Code:
sudo nano /etc/inetd.conf
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever -localhost -password

sudo - Run as Super User (Super User DO)
nano - A text editor
/etc/inetd.conf - The file you want to edit

Then you just need to add or edit the second line into text file from within the nano editor.


Sorry, I tend to forget that people switch to Linux and don't necessarily dive into the command line...
If you'd rather use a nice graphical editor to edit the file, do something like this:

Code:
sudo gedit /etc/inetd.conf


It is exactly as Edd explained, but will use GNOMEs graphical editor (like notepad) to edit the file.

After looking here:
http://www.faqs.org/docs/securing/chap5sec36.html

I've found this much out about the file:
Quote:
inetd, called also the super server, will load a network program based upon a request from the network. The inetd.conf file tells inetd which ports to listen to and what server to start for each port.


In my mind, that is exactly what you want to do. You may not even need the -forever option, though I'm not sure...

Author:  koli [ Thu Jun 03, 2010 6:45 pm ]
Post subject:  Re: Adding option to command line

In that file I had:
Code:
#<off># sane-port   stream   tcp   nowait   saned:saned   /usr/sbin/saned saned

I added this:
Code:
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever -localhost -password

And this is what it looks like now:
Code:
#<off># sane-port   stream   tcp   nowait   saned:saned   /usr/sbin/saned saned
5900    stream  tcp4     nowait  root    /usr/sbin/tcpd /usr/local/bin/x11vnc.sh -forever -localhost -password


But I don't think the this is correct as it is not having any effect. Is the syntax correct? I am not sure whether to replace stuff or just add it.
Also, when I change the file, do I need to reboot for it come into effect or is it gonna work on the fly?

Author:  EddArmitage [ Thu Jun 03, 2010 7:10 pm ]
Post subject:  Re: Adding option to command line

koli wrote:
But I don't think the this is correct as it is not having any effect. Is the syntax correct? I am not sure whether to replace stuff or just add it.
Also, when I change the file, do I need to reboot for it come into effect or is it gonna work on the fly?

I don't know about the rebooting, but try putting the last bit in back-ticks or double quotes, as Ben suggested would be my first thing.

Author:  forquare1 [ Thu Jun 03, 2010 8:05 pm ]
Post subject:  Re: Adding option to command line

You may need to alert the daemon that reads that file that the file has changed...
There may be several ways to do this, but the most universal is to do a reboot (you might be able to just restart the service, or even pass something to the service to tell it to check the file, but I don't know that much about Linux I'm afraid)

Author:  koli [ Thu Jun 03, 2010 8:13 pm ]
Post subject:  Re: Adding option to command line

Ok, I have done some googling and this is what I've found:

Quote:
Run the terminal command: x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800


If I run that in terminal it does exactly what I need:
1. It asks me for a password
2. When I disconnect I can connect again without having to terminate the session and reboot

So the question is: How do I get that command to run in terminal at startup?

Author:  forquare1 [ Thu Jun 03, 2010 8:22 pm ]
Post subject:  Re: Adding option to command line

OK, I've done more googling too.

I think this will work:
Code:
sudo echo "x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800" > "/etc/init.d/x11vnc.sh"
sudo chmod +x /etc/init.d/x11vnc.sh
sudo ln -s /etc/init.d/x11vnc.sh /etc/rc2.d/S99x11vnc


After doing this you will have to do a single reboot, then the service is active. It should be available every time you boot your machine.

From here:
http://ubuntuforums.org/showthread.php?t=673126

Author:  koli [ Thu Jun 03, 2010 9:18 pm ]
Post subject:  Re: Adding option to command line

Thanks Ben,

that code created the file with the text I wanted and made it executable but after reboot it didn't work. I think it might have something to do with the third line of code.

However this worked from that link you gave me:
Quote:
To make x11vnc run after you login go to System/Preferences/Sessions/Startup Programs and add your command


And it is working as it should. After reboot it starts x11vnc, when I try to connect it asks for a password and after I disconnect I can connect again.

Thank you very much guys for your help. I will write (very simple) "How to" for this when I have some time couple of weeks. It might save somebody the hassle I've had with it.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/