You are not logged in.

#1 2010-05-29 20:46:47

goosed
Member
Registered: 2009-03-16
Posts: 24

RDP Capability Needed

I am looking to setup some computers as thinclients to connect to my MS Terminal Servers. We have a homebrew application that configures RDP sessions. A user logs into a webpage that dynamically generates a "launch.rdp" file. This file is generated to balance the load between servers.

What I'd like to do is configure an image to boot up into Mozilla. When the user goes to the webpage, I'd like the launch.rdp file to open up in a terminal server session.

I've tried with rdesktop and tsclient, but unfortunately neither would work with a "rdp" file. Any help or suggestions are appreciated. Thanks!

Offline

#2 2010-05-29 22:31:34

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: RDP Capability Needed

I was pretty sure the last time I tried tsclient it did work with .rdp files. Doing a quick google search shows that it should still be the case. Maybe you're doing it wrong?


neutral

Offline

#3 2010-05-29 23:05:48

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Very possible. What I did to install tsclient was build it using http://aur.archlinux.org/packages.php?ID=24074. When I open the .rdp file, I choose to open it with /usr/bin/tsclient. When I do that, it opens up the tsclient gui instead of the actual rdp connection. Any ideas as to what I can do?

Offline

#4 2010-05-29 23:07:34

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: RDP Capability Needed

Oh right. I opened the rdp from tsclient. I'm not sure if you can use xdg-open to open the file the way you are.


neutral

Offline

#5 2010-05-29 23:34:45

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

So are there any options? I refuse to believe that this isn't possible with Linux.

Offline

#6 2010-05-30 00:08:19

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

Why not just parse the .rdp file with some sort of bash wrapper and create a connection command that, say, rdesktop would understand? It's all colon delimited and would be fairly easy to pick out the needed fields to get going.

Offline

#7 2010-05-30 01:08:05

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

That's a good idea. The way it works now is a Solaris server checks our MS Terminal Server resources, and dynamically generated an .rdp file for the server with the most available resources. I'll get with our vendor to see if they have the capability to create an RDP session for rdesktop.

Offline

#8 2010-05-30 01:35:13

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

I'm playing around with it now, and just wanted to see if you had any suggestions. Here's what I have on my webserver:

launch.sh

#!/bin/sh
/usr/bin/rdesktop -d DOMAIN -g 1024x768 172.16.10.117

When I click on the file from Firefox, I get an option to open the file or save it. I choose to open it with rdesktop, but unfortunately it doesn't open. Is there a better way of doing this?

Offline

#9 2010-05-30 04:36:36

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

I was thinking something more like...

#!/bin/bash

rdpfile="$1"

resolution=1024x768
server=$(grep "^full address" $rdpfile | cut -d: -f3)
domain=$(grep "^domain" $rdpfile | cut -d: -f3)

/usr/bin/rdesktop -d "$domain" -g "$resolution" "$server"

And then run that as: `parserdp rdpfile.rdp`.

Actually, you might be able to just open the .rdp file with this script...

Offline

#10 2010-05-30 04:44:50

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Yeah being a noob I was trying to open it up with xterm and rdesktop directly. I choose "bash" in Firefox and it worked out great. Now if I can only convince my vendor to change their side we'll be in business. Thanks for the help all.

Offline

#11 2010-05-30 19:17:13

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Actually moving further, do you know of a way to pull something out of the launch.rdp file? For example if I wanted to pull the address out of it and open it with a script would that be possible?

Offline

#12 2010-05-31 01:50:11

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

I made a little modification to the script you wrote:

#!/bin/bash

rdpfile="$1"

resolution=1024x768
server=$(cat launch.rdp | sed -n "21p" | sed 's/^.\{30\}//g')

/usr/bin/rdesktop -d Domain -g "$resolution" "$server"

With this it takes the downloaded launch.rdp file and strips out only the host address. It works if I just run the script by itself. However I need this to work when opening from Firefox; I.E when downloading the rdp file. Any ideas?

Last edited by goosed (2010-05-31 02:00:07)

Offline

#13 2010-06-01 01:46:59

LeoSolaris
Member
From: South Carolina
Registered: 2008-03-30
Posts: 354

Re: RDP Capability Needed

Well...   you could use the Preferences -> Application setting for .rdp files in Firefox to automatically use this script to open the file. (The easy way)

Or you could build a simple firefox addon that would accomplish it. (harder and a little less elegant, though with a lot of work, you might be able to get it to appear inside the browser. Cool looking and flashy, but it would likely be a little more taxing on the system.)


I keep getting distracted from my webserver project...

huh? oooh...  shiny!

Offline

#14 2010-06-01 01:52:50

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

goosed wrote:

I made a little modification to the script you wrote:

#!/bin/bash

rdpfile="$1"

resolution=1024x768
server=$(cat launch.rdp | sed -n "21p" | sed 's/^.\{30\}//g')

/usr/bin/rdesktop -d Domain -g "$resolution" "$server"

With this it takes the downloaded launch.rdp file and strips out only the host address. It works if I just run the script by itself. However I need this to work when opening from Firefox; I.E when downloading the rdp file. Any ideas?

This is bad, because it depends on the file providing the server on the 21st line and none other. I used grep and cut because it's a more general solution that holds to the format of the file. Of course, now that I think about it, awk is even better for this..

server=$(awk -F: '/^full address/{print $3}' "$rdpfile")

Offline

#15 2010-06-01 02:04:38

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

falconindy, when I run the script now with awk (./script.sh launch.rdp) I get cannot resolve host. What am I missing?

LeoSolaris, when I go to open the file in Firefox I choose "Open with..." and select the script. It unfortunately doesn't do anything. Weird because when I run it from the command line it does work.

Thanks again guys.

Offline

#16 2010-06-01 02:48:44

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

Run the awk command alone on the file and see what the output is.

Offline

#17 2010-06-01 03:01:37

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Here is what I'm running at the command line:

awk -F: '/^full address/{print $3}' "launch.rdp"

And there's no output.

Offline

#18 2010-06-01 04:55:22

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

Then the file isn't the format I'm expecting... could you post an example?

Offline

#19 2010-06-01 14:03:15

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Sure, here's what it contains:

screen mode id:i:2
desktopwidth:i:1280
desktopheight:i:1024
session bpp:i:24
winposstr:s:2,3,0,0,800,600
full address:s:172.16.0.117
compression:i:1
keyboardhook:i:2
audiomode:i:0
redirectdrives:i:1
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
displayconnectionbar:i:1
autoreconnection enabled:i:1
username:s:User
domain:s:America
alternate shell:s:
shell working directory:s:
disable wallpaper:i:0
disable full window drag:i:0
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1

Offline

#20 2010-06-01 14:58:52

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

Outputs run against that exact file:

$ sed -n "21p" launch.rdp | sed 's/^.\{30\}//g'
disable full window drag:i:0
$ awk -F: '/^full address/{print $3}' launch.rdp
172.16.0.117

There's a bit of a disconnect here... (no pun intended)

Offline

#21 2010-06-01 17:45:11

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

What am I doing wrong here?? When I run the awk command from the shell I don't get any output. And my bad on the launch.rdp file. Here is what it contains exactly:

screen mode id:i:2
use multimon:i:0
desktopwidth:i:1280
desktopheight:i:1024
session bpp:i:16
winposstr:s:0,3,1462,116,2486,854
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:192.168.10.105
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
redirectdirectx:i:1
autoreconnection enabled:i:1
authentication level:i:2
enablecredsspsupport:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
use redirection server name:i:0

Offline

#22 2010-06-01 17:48:55

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

When I try the awk command on the initial file it does work correctly. Why doesn't it work for the newer one?

Sorry for the confusion, and thank you for your patience.

Last edited by goosed (2010-06-01 17:56:22)

Offline

#23 2010-06-01 18:12:22

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: RDP Capability Needed

likely you've got CRLF issues. 

awk -F ':' '/^full address/ {print $3}' test.rdp
192.168.10.105

do yourself a favor and copy paste the more recent rdp file into a fresh linux file and try again (vim also has a conversion command but i can never remember it).

Last edited by brisbin33 (2010-06-01 18:12:44)

Offline

#24 2010-06-01 18:31:27

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: RDP Capability Needed

awk does what it advertises on this file too... not sure what you're doing wrong. This is an Arch box with gawk, right?

try sed:

sed -n '/^full address/s/.*:\(.*\)$/\1/p' launch.rdp

or grep...

grep -oE '[[:digit:]]+.[[:digit:]]+.[[:digit:]]+\.[[:digit:]]+' launch.rdp

or pure Bash!

while read line; do
  try=${line##*:};
  [[ $try =~ [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ ]] && echo $try
done < launch.rdp

Overboard:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FULLADDRESS   "full address:s:"

int main(void) {
  char *buffer;
  FILE *fd;

  buffer = calloc(1, BUFSIZ);

  fd = fopen("launch.rdp", "r");

  if (!fd)
    exit(EXIT_FAILURE);

  while (fgets(buffer, BUFSIZ, fd))
    if (strstr(buffer, FULLADDRESS)) {
      printf("%s", buffer + strlen(FULLADDRESS));
      break;
    }

  free(buffer);
  fclose(fd);

  return 0;
}

edit: i need more sleep... brisbin's probably onto something...

Last edited by falconindy (2010-06-01 18:36:59)

Offline

#25 2010-06-03 19:39:10

goosed
Member
Registered: 2009-03-16
Posts: 24

Re: RDP Capability Needed

Thank you for all the replies and suggestions guys! Much appreciated.

Offline

Board footer

Powered by FluxBB