August 2014
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728293031
155

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

Connecting to Windows 7 Remote Desktops (RDP) from Fedora 14 using the app FreeRDP

Background

In newer versions of Remote Desktop (RDP) that are included with Vista, Win 7, and Win Server 2008, RDP now includes something called NLA. Existing clients under Linux don’t appear to support this type of authentication, except for one, called FreeRDP.

rdesktop/tsclient

rdesktop is a RDP client specifically for Linux. However it doesn’t appear to work with newer versions of Windows RDP server.
For example, when trying to connect using rdesktop I would get the following messages:

1
2
3
4
% rdesktop -u some.user -p - -d CORP -g 1440x900 -P 192.168.1.105
Autoselected keyboard map en-us
Password: 
ERROR: recv: Connection reset by peer

Trying the same thing from tsclient, a frontend GUI that uses rdesktop underneath, I get essentially the same problem, except with a more descriptive dialog box.

Terminal Server Client (tsclient main window)

tsclient main window

Terminal Server Client (connection properties)

tsclient connection properties

Terminal Server Client (failed connection)

tsclient failed connection

Windows XP’s RDP Client

Using the RDP client included with Windows XP had a similar effect.

Windows XP RDP client error dialog

RDP client error dialog


…. Continue reading → Connecting to Windows 7 Remote Desktops (RDP) from Fedora 14 using the app FreeRDP »»

How to Recover Corrupt jpeg and mov Files from a Digital Camera's SDD Card on Fedora/CentOS/RHEL

Background

Have you ever had a digital camera SDD card get corrupt and become unreadable? Through the use of the handy tool photorec, all the files on the card can be recovered.

Installation

First you need to install photorec. It’s included in a package called testdisk. This package was available in the CentOS/RHEL epel repos as well as the Fedora 14 repo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% sudo yum install testdisk
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package testdisk.x86_64 0:6.11-6.fc12 set to be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================================================================================
 Package                        Arch                         Version                             Repository                    Size
====================================================================================================================================
Installing:
 testdisk                       x86_64                       6.11-6.fc12                         fedora                       257 k
 
Transaction Summary
====================================================================================================================================
Install       1 Package(s)
 
Total download size: 257 k
Installed size: 859 k
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 257 k
testdisk-6.11-6.fc12.x86_64.rpm                                                                              | 257 kB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : testdisk-6.11-6.fc12.x86_64                                                                                  1/1 
 
Installed:
  testdisk.x86_64 0:6.11-6.fc12                                                                                                     
 
Complete!

Example Use

First put your SDD card into a card reader attached to your Linux box. Next you’ll need to run photorec.

1
% photorec

photorec #1

photorec #2


…. Continue reading → How to Recover Corrupt jpeg and mov Files from a Digital Camera’s SDD Card on Fedora/CentOS/RHEL »»

[one-liner]: Putting Images Side by Side in a Wordpress Post

Background

Have you ever had the need to put 2 thumbnails side by side and centered in a blog post in WordPress? Here’s how.

Solution

The approach below is to use div tags within another div tag that controls how the “child” divs are aligned.

1
2
3
4
5
6
7
8
9
<div style = "text-align:center">
 <div style="display: inline-block; margin-right: 50px">
   .... IMAGE ....
 </div>
 
 <div style="display: inline-block">
   .... IMAGE ....
 </div>
</div>

Example #1

NOTE: centered within the browser window

1
2
3
4
5
6
7
8
9
<div style = "text-align:center">
 <div style="display: inline-block; margin-right: 50px">
   [caption id="" align="alignnone" width="58" caption="Left Image"]<img alt="Left Image" src="http://www.lamolabs.org/blog/wp-content/themes/atahualpa/images/logo.gif" title="Left Image" width="58" height="45" />[/caption]
 </div>
 
 <div style="display: inline-block">
   [caption id="" align="alignnone" width="58" caption="Right Image"]<img alt="Right Image" src="http://www.lamolabs.org/blog/wp-content/themes/atahualpa/images/logo.gif" title="Right Image" width="58" height="45" />[/caption]
 </div>
</div>
Left Image

Left Image


Right Image

Right Image


Example #2

NOTE: aligned to code box

1
2
3
4
5
6
7
8
9
<div style = "margin-left: 10%">
 <div style="display: inline-block; margin-right: 50px">
   [caption id="" align="alignnone" width="58" caption="Left Image"]<img alt="Left Image" src="http://www.lamolabs.org/blog/wp-content/themes/atahualpa/images/logo.gif" title="Left Image" width="58" height="45" />[/caption]
 </div>
 
 <div style="display: inline-block">
   [caption id="" align="alignnone" width="58" caption="Right Image"]<img alt="Right Image" src="http://www.lamolabs.org/blog/wp-content/themes/atahualpa/images/logo.gif" title="Right Image" width="58" height="45" />[/caption]
 </div>
</div>
Left Image

Left Image


Right Image

Right Image


NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

[one-liner]: Using Imagemagick to convert PNG files to a single PDF

Background

Recently I had the need to do some documentation which was going to be heavy on screen shots and light on text.

Solution

So I opted to simply just take a stack of screen shots and simply annotate them using the awesome screen shooting package shutter.

shutter's main window


shutter's image editor


Once I finished that phase I needed to put them into a single file. As I saw it I had only 3 options:

  • openoffice.org writer file (.odt/.sxw)
  • openffice.org impress file (.odp/.sxi)
  • .pdf

I opted to put them in a single PDF file. So the next question was how? Being a command line guy I started googling around and came across this method using Imagemagick’s convert command.

1
convert -define pdf:use-trimbox=true *.png slidedeck_chp1.pdf

References

links
local copies

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

[one-liner]: Dynamic Variables Names in Bash

Background

I hate when people make little shell scripts that all do essentially the same thing. For example:

1
2
3
4
process_moe_dir.bash
process_larry_dir.bash
process_curly_dir.bash
process_schemp_dir.bash

Here’s a technique to roll these all into a single shell script that you can just call with a command line argument.

Solution

Instead of creating the 4 scripts above, we’re going to create just one script like this one below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
 
# vim: ts=2
moe_dir="/path/to/moe"
larry_dir="/path/to/larry"
curly_dir="/another/path/to/somewhere/curly"
schemp_dir="/another/path/to/somewhere/else/schemp"
 
case "$1" in
  moe|larry|curly|schemp )
    cmd_arg="$1"
    active_dir=$(eval "echo \${$(echo ${cmd_arg}_dir)}")
    echo "active_dir: $active_dir"
    echo ""
  ;;
 
  * )
    echo ""
    echo "USAGE: `basename $0` [moe|larry|curly|schemp]"
    echo ""
    exit 1
  ;;
esac

Here’s the script in action:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
% ./dyn_variable_ex.bash 
 
USAGE: dyn_variable_ex.bash [moe|larry|curly|schemp]
 
% ./dyn_variable_ex.bash moe
active_dir: /path/to/moe
 
% ./dyn_variable_ex.bash larry
active_dir: /path/to/larry
 
% ./dyn_variable_ex.bash curly
active_dir: /another/path/to/somewhere/curly
 
% ./dyn_variable_ex.bash schemp
active_dir: /another/path/to/somewhere/else/schemp

The key concept in the above script is the notion of dynamic variable names. This is the line that makes the dynamic variables work.

1
active_dir=$(eval "echo \${$(echo ${cmd_arg}_dir)}")

Within this line are 2 commands, in the form of $(…).

NOTE: one of these is nested inside of the other i.e. $( $() ).

… so for example: say ${cmd_arg} = moe

  • The inner: $(..) –> $(echo ${cmd_arg}_dir) echoes the string moe_dir.
  • The outer: $(..) –> $(eval “echo \${moe_dir}”) echoes the contents of $moe_dir

Useful Links

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

Working with the Gnome Desktop from the Command Line Using wmctrl

Background

Have you ever wanted to minimize a window from a script, or make another window fullscreen from the command line? Or maybe get a list of all the windows that are currently open on all your virtual desktops, from a shell? Then the tool you’ve been looking for is wmctrl.

Solution

For those that are die hard command line users, wmctrl is a power users tool which can be used to accomplish a variety of tasks, that most would think are only achievable with a mouse.

wmctrl is a UNIX/Linux command line tool to interact with an EWMH/NetWM compatible X Window Manager.

The tool provides command line access to almost all the features defined in the EWMH specification. It can be used, for example, to get information about the window manager, to get a detailed list of desktops and managed windows, to switch and resize desktops, to make windows full-screen, always-above or sticky, and to activate, close, move, resize, maximize and minimize them.

Example Use Cases
  • 1: List all desktops managed by WM
1
2
3
4
5
6
7
8
9
10
11
12
% wmctrl -d
0  - DG: 5760x900  VP: 0,0  WA: 0,25 1440x826  Workspace 1
1  - DG: 5760x900  VP: 0,0  WA: 0,25 1440x826  
2  * DG: 5760x900  VP: 0,0  WA: 0,25 1440x826  N/A
3  - DG: 5760x900  VP: 0,0  WA: 0,25 1440x826  N/A
 
# NOTES: col1 = desktop #
#        col2 = active desktop (has a *)
#        DG:  = Desktop Geometry
#        VP:  = Viewport Position
#        WA:  = Workarea Geometry
#        The last column is the name, if any is set, for the desktop
  • 2: List All Windows (includes process id + geometry)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
% wmctrl -l -p -G
0x05005bfe -1 0      360  688  1080 212  grinchy N/A
0x07000084  0 4776   256  168  1182 690  grinchy Inbox - Mozilla Thunderbird
0x06201afe  2 8578   0    98   1440 801  grinchy Untitled 1 - OpenOffice.org Writer
0x00c00003 -1 2040   0    0    1440 25   grinchy Top Panel
0x00c00028 -1 2040   0    1702 1440 49   grinchy Bottom Panel
0x06001118  2 2859   978  100  947  397  grinchy saml@grinchy:~
0x0643835b -1 6571   0    98   1440 801  grinchy Edit Post ‹ Lâmôlabs — WordPress - Mozilla Firefox
 
# NOTES: col1   = the window identity as a hexadecimal integer
#        col2   = -1 - sticky window, # - desktop window belongs to
#        col3   = process id
#        col4-7 = geometry (x-offset, y-offset, width and height)
#        col8   = machine name (i.e. grinchy)
#        col9   = title of window
  • 3: List All Windows (same as above without the process id & geometries)
1
2
3
4
% wmctrl -l
0x05005bfe -1 grinchy N/A
0x07000084  0 grinchy Inbox - Mozilla Thunderbird
...
  • 4: Activate a Window by name
1
% wmctrl -a firefox
  • 5: Toggle fullscreen on active window
1
% wmctrl -r :ACTIVE: -b toggle,fullscreen
  • 6: Close a window
1
2
3
4
5
6
7
8
9
10
11
# list all windows
% wmctrl  -l
0x06001118  2 grinchy saml@grinchy:~
0x06006673  2 grinchy saml@grinchy:/home
 
# close a window
% wmctrl -F -c 'saml@grinchy:/home'
 
# check that windows closed
% wmctrl  -l
0x06001118  2 grinchy saml@grinchy:~

Useful Links

Page 6 of 14« First...45678...Last »