Most of the stuff I do is via the shell, but once in a while need to attach to an existing X session on my work desktop. My requirements are that the method:
- Uses SSH for authentication
- Tunnels VNC traffic over SSH for security and so no additional ports need to be opened
x11vnc is what I’ve been using. Here’s a little shell script I wrote that will take user@hostname as a variable, enumerate an existing GDM session on the remote computer, create an SSH tunnel and attach to it via VNC. It uses aggressive compression, which looks a bit ugly but still works over a low bandwidth connection. The auth file enumeration bit works with Gnome, but could probably be adapted for use with other window managers.
Pad filenames starting with a single digit year (e.g. 1, 2, etc) with a zero while leaving filesnames starting with two digit years (e.g. 11, 12) untouched.
The shell one line script below will:
1. Find all files below current dir
2. Rename the file with download Source and date range as part of the new file name
3. Renamed file will stay at current location (e.g. file “./path/to/dir/crappyname” becomes “./path/to/dir/DC.Circuit-2006.06.02-2006.07.01.txt”)
To trim a video clip, mencoder and ffmpeg expect a start time in hh:mm:ss, but instead of end time, want duration:
$ mencoder -ss 00:02:55 -endpos 00:07:15 -oac copy -ovc copy in.avi -o out.avi $ ffmpeg -ss 00:02:55 -t 00:07:15 -vcodec copy -acodec copy -i in.avi out.avi
Video players make it easy to identify start/stop times, but difficult to figure out duration, so I wrote a little shell script that will calculate duration from start/stop times.
Usage example:
$ calc-duration 00:02:55 00:10:10 Start: 00 hrs 02 min 55 sec Stop: 00 hrs 10 min 10 sec +----------------------+ | duration is 00:07:15 | +----------------------+
Display all lines from file except lines between two lines matching a pattern:
1 | sed '/10\/02\/1992/,/01\/02\/2001/d' input.txt |
Display lines between two lines matching a pattern:
1 | sed -n '/10\/02\/1992/,/01\/02\/2001/p' input.txt |