icearrow
Posts: 6
Joined: Tue Feb 05, 2013 9:38 pm

Automatic RDP connection

Tue Feb 05, 2013 10:03 pm

Hello everybody, this is my first post in the Forum

As the topic subject suggest, i'm working on a thin client which is going to connect to a Windows Server 2003.

Until now I've installed rdesktop and I connect to my server via Terminal or via a simple script on my desktop like this:
#!/bin/bash
rdesktop -f myserverIP
with this method I need to start LXDE (automatically or not), then I have to run the script in order to connect to the remote session, but that's not the best way if I only need the remote session.
Looking on the internet I've found a way to avoid the use of LXDE, simply by startin X and then an istance of rdesktop redirected to the X display, It's a little bit tricky but there is no need of a Window Manager at all:

On the first shel session just write X to start the Xserver without any Desktop enviroment, then switch to a 2nd shell with Alt-Ctrl-F2 and run DISPALY=:0 rdesktop -f myserverIP (use -f in order to fill the entire screen with the remote session).

Now, as I said before, this is a little bit tricky and her is my question: Is there any way to create a script with the opening instance of X and the rdesktop command?
I've tried to write down a script but it doesn't work:
#!/bin/bash
X
DISPLAY=:0 rdesktop -f myserverIP

User avatar
topguy
Posts: 6637
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Automatic RDP connection

Tue Feb 05, 2013 10:19 pm

You need to start X in the background and take a small pause before starting rdesktop, thats all.

Code: Select all

X &
sleep 10
DISPLAY=:0 rdesktop -f myserverIP

icearrow
Posts: 6
Joined: Tue Feb 05, 2013 9:38 pm

Re: Automatic RDP connection

Tue Feb 05, 2013 10:26 pm

Thanks, It's working. :D

kghunt
Posts: 383
Joined: Sun Mar 04, 2012 9:28 am

Re: Automatic RDP connection

Tue Feb 05, 2013 10:56 pm

I used to do something similar but also used watch

Code: Select all

X &
sleep 10
DISPLAY=:0 watch -n 1 rdesktop -f myserverIP
That will keep trying the rdp every second, good if the session times out or gets disconnected.

Viriiguy
Posts: 13
Joined: Sun Jul 17, 2016 2:26 pm

Re: Automatic RDP connection

Mon Jul 25, 2016 2:50 pm

I know this is an ANCIENT topic, but it is exactly what I need.. I think.

However, I am an idiot I guess...

Where and I supposed to put this?
X &
sleep 10
DISPLAY=:0 watch -n 1 rdesktop -f myserverIP

User avatar
topguy
Posts: 6637
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Automatic RDP connection

Tue Jul 26, 2016 9:46 am

I suggest putting them in a script file called for example "myrdp.sh" and test it.

Code: Select all

#!/bin/bash
X &
sleep 10
DISPLAY=:0 rdesktop -f myserverIP
If you want this to start automatically on boot then its another discussion.

Return to “Networking and servers”