#!/usr/bin/perl -w
#
# azlyricfilter.pl - filters HTML from www.azlyrics.com into text
#
# Run this on the output of 'html2text -nobs azlyricsURL e.g.
#
# html2text -nobs http://www.azlyrics.com/lyrics/u2/exit.html\
# | azlyricfilter.pl > u2-exit.txt
#
# The -nobs keeps html2text from marking up the text w/ BS and over-
# strike characters.
#
# This program requires the html2text program.
#
# Revision History:
# 2005-10-31: pdwilso@gmail.com - initial version
#
$start=1;
while (<>) {
chomp;
next if ($start && /LYRICS/);
next if ($start && /^\s*$/);
if(/^\s*\"/) {$start=0;}
exit if(/\[ www.azlyrics.com \]/);
s/^\s*//g;
print;
print"\n";
}
#!/usr/bin/perl -w
#
# mkogg.pl - this program converts .flac files in directory to .ogg
#
# This program accepts no arguments or parameters - the input
# filenames are read from the current directory.
#
# Filenames are assumed to have have the following data:
#
# artistname-albumname-trackno-songtitle.flac
#
# Each of the fields separated by '-' (artistname, albumname,
# trackno, and songtitle) contain underscores ('_') where the
# spaces should be. No special characters are supported in
# the input (.flac) file names, so set up the ripping and
# flac encoding appropriately.
#
# The FLAC decoding and OGG encoding operations are spawned as
# child processes to this process. There should probably be some
# sort of monitoring here that would reap the child PIDs if
# something goes wrong.
#
# This software depends on the FLAC decoder flac(1) and the OGG
# encoder oggenc(1) being installed and available in the path.
#
# Revision History:
# 2005-10-30: pdwilso@gmail.com - Initial version
# 2005-10-31: pdwilso@gmail.com
# - Corrected really heinous error that was over-
# writing the source .flac files.
# - Corrected syntax error in code that collects
# child PID into @children array.
# - Added $QUIET and $DEBUGGING declarations.
#
$QUIET=0;
$DEBUGGING=0;
opendir(DH, ".") || die "could not open current working dir : $!";
@flacs = grep { chomp, /\.flac$/ } readdir DH;
closedir DH;
@children = ();
unless ($QUIET) {
print "Found ".scalar(@flacs)." FLAC files...\n";
}
foreach my $flac (@flacs) {
if (my $pid=fork) {
push @children, $pid;
} else {
my ($artist,$album,$track,$title) = split(/-/,$flac);
$title=~s/\.flac$//;
foreach my $s ($artist,$album,$title) {
$s=~s/_/ /g;
$s=~s/\W([a-z])/ \U$1/g;
$s=~s/^([a-z])/\U$1/;
}
my $ofile = $flac;
$ofile =~ s/flac$/ogg/g;
my $params=
"-a '$artist' ".
"-t '$title' ".
"-l '$album' ".
"-o $ofile ".
"-N $track";
unless ($QUIET) {
print "Converting $flac to\n $ofile ...\n";
}
if ($DEBUGGING) {
"COMMAND: ",
"flac -s -d -c $flac | oggenc -Q $params -\n";
}
my $output= `flac -s -d -c $flac | oggenc -Q $params -\n`;
unless ($QUIET) {
print "$ofile done.\n";
}
exit;
}
}
<?php
////////////////////////////////////////////////////////////////
//
// m3u.php - create a playlist from a directory listing
//
// This program collects a list of MP3 files in a directory on
// the web server and creates an .m3u playlist suitable for
// passing to to e.g. XMMS from a URL within a webpage or
// typed into a browser location bar.
//
// The program expects to be run from within the same
// directory as the MP3 files that it will list - that means
// that in the *nix world we typically just place this program
// file in the same directory as the music files.
//
// This program was tested using Apache webserver under SuSE
// 9.2, Firefox 1.07 web browser, and Xmms 1.2.10.
//
// Not sure of the Apache version - it is completely stock
// (but with updates installed).
//
// The client-side tests were run in a KDE desktop environment
// under both SuSE 9.1 and SuSE 9.2 - again, these are stock
// environments with nothing special done to them except
// routine updates.
//
// Correctly behavior for this script means that the web
// browser prompts for "Save this file or open using XMMS" and
// when XMMS is selected the playlist actually loads and plays
// as expected.
//
// This behaviour does not occur using existing playlist
// transfer code found on the web. Specifically, code that
// uses 'Content-Type: audio/x-mpegurl' triggers loading to
// XMMS but does not actually play.
//
// For other content types tried in the test environment
// described above: The 'audio/mpegurl' type does play
// correctly. The audio/mpeg and audio/x-mpeg types don't
// work, either (alhthough both of those do seem to work for
// single (individual) MP3 files.
//
// This program could be easily adapted to handle other media
// types.
//
// Credits:
// The HTTP header code is modified from an example found on
// the web. The Content-Type string is changed from the
// example.
//
// Revision History:
// 2005-10-30: pdwilso@gmail.com - initial version
//
////////////////////////////////////////////////////////////////
//
// Get input params...
//
// We're not doing anything here, yet...
//
$m3ufn=$_GET['file'];
// Modify this to allow users to supply a playlist filename or
// to provide a more desciptive filename for the playlist.
if (!($m3ufn === 'pl.m3u')) {
$m3ufn='pl.m3u';
}
//
// Get the environment we're running in, and create a base URL
// to use in constructing the invidividual song pointers.
//
$host=$_SERVER['SERVER_NAME'];
$DOCBASE = $_SERVER['DOCUMENT_ROOT'];
$len = strlen($DOCBASE);
$url='';
// Need to change this if you're not under *nix - $str gets the
// name of the current working directory.
$str = rtrim(`pwd`);
// The dir seperator here is *nix specific ('/')
$pelem = explode('/',substr($str,$len));
foreach ($pelem as $s) {
$url .= '/'.urlencode("$s");
}
//
// Construct a list of files...
//
// The list is an array of filenames for files in this (the
// current working directory) directory whose extensions match
// the type(s) of files we're looking for.
//
// Right now we're just handling MP3 - note that this is case
// sensitive - were just handling lower case 'mp3'
//
$dh = opendir(".");
while (($f=readdir($dh)) != false) {
// Change this regex to include e.g. .ogg files in the
// listing that will go to the player - if you change this
// to include e.g. video files, be sure to handle the
// Content-Type header, below, as well...
if (preg_match('/mp3$/',$f)) {
$files[] = urlencode($f);
}
}
closedir($dh);
sort($files);
//
// Create the output content...
//
// Not sure if the DOS line terminators are significant
// here, but it seems to work, so we leave it in.
//
$text="#EXTM3U:\r\n";
foreach ($files as $f) {
$u = "http://$host$url/$f";
$text.= "$u\r\n";
}
// Send it...
header("Pragma: no-cache"); // HTTP/1.0
header("Cache-Control: private"); // HTTP/1.1
header("Content-Type: audio/mpegurl", TRUE);
header("Content-Length: ".strlen($text)."", TRUE);
header("Content-Disposition: attachment; filename=\"".$m3ufn."\"", TRUE);
print $text;
?>
OVERVIEW:
This paper outlines - in a very general way - the steps needed to
set up VNC servic on a host machine such that VNC will provide
remotely accessible, multi-user graphical loging functionality on a
Unixish server.
Additionally, these steps include information about how to custom-
tailor the Xvnc configuration such that connection to various
defined ports can provides specified client screen resolution.
Using well-crafted VNC startup initialization scripts in concert
with the named port mapping technique shown here, these methods
could could produce highly customized. specialized services on VNC
service ports in the specified range.
Ports may be named appropirately, and portions of the configuration
scripts may be dynamic.
PRECONDITIONS:
The the following conditions should pertain for the host which is to
provide the VNC service:
* is running the display manager XDM (X-windows Display Manager)
* is running the Internet meta-deamon INETD
* has Xvnc installed
Additionally, the user performing the configuration must have system
administrative privileges for the host.
STEPS:
1. Add VNC User account
the VNC server application runs as this user. This should be
generic system user ID, a bit like the user 'nobody' which
Apache runs as.
2. Add VNC Port names to /etc/services
VNC uses TCP/IP ports 5900 to 5999. These ports map to display
numbers in VNC client connect strings, and by inetd (or xinetd)
to start the VNC service.
3. Add VNC service definitions to /etc/inetd.conf
For each VNC port name defined in step 2, above, a line is
placed in the /etc/inetd.comf file. These are standard inetd
configuration / invocation syntax definitions that are used to
configure services that are requested via inetd.
4. Modify Display Manager startup scripts
a) /etc/X11/xdm/Xaccess
The file /etc/X11/xdm/Xaccess contains rules which control
access to the XDM display manager. These rules must remote
access to XDM in order that remote users be able to use XDM
for login.
The simplest way to accomplish that is to simply place a
single asterick character (*) on a line by itself in this
file.
For example. an /etc/X11/xdm/Xaccess rule allowing access to
Xdm from any network host is:
* # any host can get a login window
b) /etc/X11/xdm/xdm-config
Comment out the DisplayManager.requestPort line.
5. Restart System Services XDM and INETD
% /etc/init.d/xdm restart
% /etc/init.d/inetd restart
NOTES:
For additional information about XDM initialization and
configuration, see the XDM manual pages.
For additional information about VNC session startup initialization,
see the VNC documentation.
For additional information about INETD and the /etc/services file,
see the manual pages for those.
EXAMPLE FOR /etc/services FILE:
## ===========================================================
## /etc/services Modifications
## VNC services using ports 5900 thru 5999
## ---------------------------------------------------------
# name port/proto resolution screen number
# ------------ -------------- --------------- -------------
vnc 5900/tcp # site default :0
vnc-tiny 5901/tcp # 320x240 :1
vnc-small 5902/tcp # 640x480 :2
vnc-med 5903/tcp # 800x600 :3
vnc-large 5904/tcp # 1024x764 :4
vnc-xlrg 5905/tcp # 1280x1024 :5
vnc-huge 5906/tcp # 1600x1200 :6
vnc-cust 5907/tcp # 1160x960 :7
## ===========================================================
EXAMPLE FOR /etc/inetd.conf FILE:
# ============================================================
# Add to /etc/inetd.conf
# ===========================================================
# Start VNC services based on TCP port name.
#
# In this example, ports are named for their resolutions.
#
# All servers in this example uses a default pixel color depth of
# 24bpp.
#
# All servers currently run under username "netcusr".
#
# Port numbers are defined in /etc/services
#
# name resolution VNC screen
# ------------- ------------- ----------
# vnc 1160x960 :0
# vnc-tiny 320x240 :1
# vnc-small 640x480 :2
# vnc-med 800x600 :3
# vnc-large 1024x768 :4
# vnc-xlrg 1280x1024 :5
# vnc-huge 1600x1200 :6
# vnc-cust 1160x960 :7
#
# ===========================================================
vnc stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 1160x960 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-tiny stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 320x240 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-small stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 640x480 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-med stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 800x600 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-large stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 1024x768 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-xlrg stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 1280x1024 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-huge stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 1600x1200 -depth 24 -desktop NetC\
-inetd -once -query localhost
vnc-cust stream tcp nowait netcusr /usr/X11R6/bin/Xvnc Xvnc\
-geometry 1160x960 -depth 24 -desktop NetC\
-inetd -once -query localhost
# ===========================================================
ADDITIONAL CONFIGURATION AND EXTENSION INFORMATION:
From the XDM manual page:
"For X terminals that do not offer a menu of hosts to get display
management from, xdm can collect willing hosts and run the
chooser program to offer the user a menu. For X displays
attached to a host, this step is typically not used, as the local
host does the display management."
...this chooser behaviour may be automated server side such that it
could select a login host form a cluster of hosts based on e.g. load
balancing parameters.
Also from the manual page:
"After resetting the X server, xdm runs the Xsetup script to
assist in setting up the screen the user sees along with the
xlogin widget."
...the Xsetup script exists as /etc/X11/xdm/Xsetup - this is the
script to customize to control what the user sees on the login
screen.
Manual page, again:
"The xlogin widget, which xdm presents, offers the familiar login
and password prompts."
...the xlogin widget resources may be specified using standard X
resource specifications. This gives fine-grained control over the
appearance and behaviour of the login widget (which displays the
'Username:' and 'Password:' prompts)...
The manual page specifies the order in which the other session setup
scripts run:
"After the user logs in, xdm runs the Xstartup script as root.
"Then xdm runs the Xsession script as the user. This system
session file may do some additional startup and typically
runs the .xsession script in the user's home directory. When the
Xsession script exits, the session is over."
...note that the ~/.vnc session initialization scripts are not be
being used, here, since the VNC service is running at a system level,
allowing the user to log in using standard X login methods. This
means that, assuming the user logins in only using VNC (i.e. never
logs in locally), the standard startup scripts may be used to
initialize the session, even though some session initialization may
be VNC-specific.
"At the end of the session, the Xreset script is run to clean up,
the X server is reset, and the cycle starts over."
...so any session tear-down should be done in Xreset. There should
also be a user-specific version of this file. If there is not, one
should be added.
To summarize: VNC can be used to set up the connection and do
authentication, following which the XDM and standard X session
configurations can be used to control the what gets displayed on the
"desktop" that the user sees following the login authenitcation
sequence.
2004/09 2005/03 2005/04 2005/05 2005/06 2005/07 2005/08 2005/09 2005/10 2005/11 2006/01 2006/02 2006/04 2006/05 2006/06 2008/01
Subscribe to Posts [Atom]