October 2007

Monthly Archive

Linux – Taking over an existing TTY session remotely

Posted by white_b on 23 Oct 2007 | Tagged as: Linux

Some of us have run across situations where we want to be able to keep user-mode programs running in a Linux TTY session, but still want to be able to manage them remotely through SSH or other means.

One solution is the ‘linuxvnc’ utility, which can grab a TTY session and display it for use in a VNC window. I will be covering this utility, as tested on Ubuntu 7.04 Feisty (although it should work for virtually any distro).

For starters, let’s grab linuxvnc from the repositories with apt:

sudo apt-get install linuxvnc

Once that is done, fire it up: (root access is required to grab TTYs)

sudo linuxvnc X

Where ‘X’ is the TTY # you want to grab. linuxvnc should indicate that it’s listening on port 5900.

You can now connect with any VNC client, such as RealVNC, KRDC, or whatever. One thing I’ve noted is that KRDC has trouble with linuxvnc sessions if it attempts to use ‘Tight’ VNC encoding. I would recommend using zlib instead.

Of course if you’re using VNC over the Internet, I strongly recommend tunneling it through SSH. That, however, is a tip for another day.

How to Convert MKV x264 to WMV for the Xbox 360 (Part 1)

Posted by walsh_r on 22 Oct 2007 | Tagged as: Media Center, Multimedia, Xbox 360

**Update Visit http://www.ryanwalsh.ca/blog/?p=8 for a new polished tutorial similar to this one, to convert all of your MKV’s to WMV (DTS support included).

Thanks again to Cody Browning for helping many of us come up with this conversion method. His original thread from xbox-scene.com can be found here.

The Xbox 360 was officially released by Microsoft on May 12, 2005, as a 7th generation gaming console, and network ready media center extender. The hardware capabilities of the Xbox 360 make it the best high definition video player on the market for its price. However, the software limitations imposed upon that hardware by Microsoft leave much to be desired by users hoping to to consolidate their living room multimedia equipment into one box. The biggest fall back of those limitations is by far the lacking support for any digital video file support other than WMV. The majority of internet available digital video content is not in WMV format.

The current popular format for internet digital high definition video content is Matroska video (MKV). MKV container files include x264 HD video content (720p, 1080i, and 1080p), along with 5.1 AC3 or DTS audio. The Xbox 360’s software limitations prevent it from being able to display MKV HD video files. This tutorial will demonstrate one method of converting MKV files into WMV-HD video files with 5.1 audio surround sound, using Windows XP or Windows Vista.

Required:

Background:

There are lots of different video codec combinations that can be used to decode MKV files, however, many of these packaged tend to have conflicting versions of video codecs (namely ffdshow) which cause unsatisfactory encodes to WMV-HD (choppiness, image quality, etc). It is my recommendation to uninstall all existing video codecs on the machine which will be used to encode the WMV-HD video, and install only the codecs listed above. Install any other future necessary codecs one at a time, and test encodes to verify that the new codecs have not introduced any problems.

Unfortunately TMPG 4.0 Express is not a free or open source product. I’ve chosen it in my demonstration because of its ease of use, flexibility of encode times/quality settings, and price.

Preparation:

  1. Uninstall all existing video codecs and reboot.
  2. Install TMPG 4.0 Express.
  3. Install Xvid
  4. Install ffdshow tryouts
  5. Install Haali Media Splitter
  6. Extract wmv-hd.zip into a temporary directory.
    1. Contents of wmv-hd.zip
      (contents of wmv-hd.zip)
    2. Install Avisynth.
    3. Install MKVtoolnix.
    4. Copy all of the files from the MKVextractGUI folder to the folder where MKVtoolnix was installed (c:\program files\MKVtoolnix by default).
  7. Create a temporary directory which will be used to store MKV files to be converted. For the remainder of this tutorial, I will refer to this directory as c:\wmv_convert\ .
    1. Copy “Xbox 360 720 VBR.txp4e” to c:\wmv_convert .

After completing the above steps, you are now ready to convert MKV (x264) to WMV-HD for the Xbox 360.

Continued on Page 2…

IIS, PHP, MySQL and Windows Server 2003

Posted by walsh_r on 16 Oct 2007 | Tagged as: Databases, Web Design

The creation of a database driven website is very simple in concept; add content to the database, and display the content on pages. The work going on behind the scenes to make this concept function, is not always so simple. There are numerous methods and products that can be used to accomplish different parts of this task, but getting them all to work nicely together can deliver headaches to anyone.

One popular combination often chosen by developers is the use of the PHP scripting language, and MySQL database. Both products are free, open source, cross platform, and have a large base of corporate and personal users.

Getting PHP and MySQL to work nicely with Windows Server 2003 and IIS can be troublesome, mostly due to the many different versions of PHP and MySQL, and the frequency that each product is updated (don’t get me wrong, free updates to products are great, once they are configured and working as expected). After experiencing some problems related to versions myself, I decided to write this tutorial on how to configure an operational MySQL database capable of interacting with PHP, IIS 6.0 on Windows Server 2003.

Required:

Background:

  1. IIS 6.0 previously installed on a Windows 2003 Server.

PHP Installation

  1. Create a folder on your root (C:) and name it PHP. (C:\PHP)
  2. Unzip the contents of the PHP 5.2.3 ZIP file to the PHP folder created in step 1.
  3. Open the IIS MMC snap-in.
    1. In the properties of the website you wish to use PHP with (most likely the default website), go to the Home Directory tab, and select Configuration.
    2. Under Application Configuration, check to see if .php is in the list. If it is, you will need to click edit and modify the Executable to C:\php\php5isapi.dll. If it is missing from the list, click add, and use C:\php\php5isapi.dll as the Executable and .php as the extension.
  4. Copy php.ini-recommended from C:\PHP to C:\Windows and rename to php.ini .
  5. Reboot.

To test the PHP installation, create a new file in notepad that contains the code below. Save the file as test.php in the root directory of your website.

<?PHP
phpinfo();
?>

Open a web browser from your web server and test http://127.0.0.1/test.php . If PHP is installed correctly, you will get a listing of the PHP configuration.

MySQL Installation

  1. Install MySQL 5.0
  2. Install the GUI tools for MySQL 5.0
  3. Run the MySQL Server Instance Config Wizard from the Start menu.
    1. Detailed Configuration
    2. Developer Machine
    3. Non-Transactional Database Only
    4. Decision Support (DSS)/OLAP
    5. Check Enable TCPIP Networking
    6. Port 3306
    7. Standard Character Set
    8. Install as a Windows Service
    9. Assign a root password (remember this password!!)

    *Remember the password that you assign to the root account! Document the password in a secure, reliable location.

  4. Launch the MySQL Administrator Program (the GUI tools installed earlier)
    1. Server host: localhost
    2. username: root
    3. password: use the password assigned above.
  5. If the tool connects and lists information about your MySQL server, then MySQL has been configured correctly.

To finish things off, we need to configure PHP to load some MySQL extensions. This will enable the web server, PHP, and MySQL to work together while server content to web pages from the MySQL database.

  1. Copy C:\PHP\libmysql.dll to C:\windows\system32\ .
  2. Open C:\Windows\PHP.ini in Notepad.
  3. Search the INI file for the following lines, and edit them to read as follows. If there is a semi-colon in front of the line, remove it.
    1. extension_dir=”c:\php\ext\”
    2. extension=php_mysql.dll
    3. extension=php_mysqli.dll
  4. Reboot.

To test the configuration, create a new file in notepad that contains the code below. Save the file as mysqltest.php in the root directory of your website. Edit the code to replace the root password with the one previously assigned.

<?PHP

//(”server name”,”username”,”password”)
$rst = @mysql_connect(”localhost”,”root”,”insert_password_here”);

if (!$rst){
echo( “<p>Unable to connect to database manager.</p>”);
die(’Could not connect: ‘ . mysql_error());
exit();
} else {
echo(”<p>Successfully Connected to MySQL Database Manager!</p>”);
}

if (! @mysql_select_db(”mysql”) ){
echo( “<p>Unable to connect database…</p>”);
exit();
} else {
echo(”<p>Successfully Connected to Database ‘MYSQL’!</p>”);
}
?>


Open a web browser from your web server and test http://127.0.0.1/mysqltest.php . If everything is configured correctly, your web browser will display Successfully Connected to MySQL Database Manager and Successfully Connected to Database ‘MYSQL’.

The Web Server is now ready to serve PHP web pages and communicate with a MySQL database.

Secure FTP and OpenSSH with Windows Server 2003

Posted by walsh_r on 12 Oct 2007 | Tagged as: Backups, Encryption

Quite a few people have asked me how to configure a secure means of transferring backup data. This tutorial outlines how to set up a Secure-FTP server using OpenSSH to encrypt the data with Windows 2003 Server, and how to set up a remote location to automatically upload backup data to the Secure-FTP server. The following method will work for any type of data.

Required:

Background:

  1. Our Secure-FTP server will be set up on a Windows 2003 Server.
  2. Our remote client who will send back up data to the Secure-FTP Server will be set up on a Windows XP workstation.

Our first step is to set up the Windows 2003 Server as a Secure-FTP server by downloading and installing OpenSSH for Windows.

  1. Install the latest binary for Windows from the OpenSSH for Windows website. Be sure to install both the server and client components.
  2. Configure the SSH server.
    1. Open a command prompt window and navigate to c:\program files\openssh
    2. Create a group file
      1. mkgroup –l >> .\etc\group
    3. Add users and create a passwd file
      1. First create any user accounts locally on the Windows Server via computer management. They do not need to be members of the Administrators group, default group membership is fine. Once you’ve created the accounts locally, adding the account names to the passwd file will enable them to log on using SSH. Do so by entering the following command for each user you would like to add to the passwd file.
      2. mkpasswd –l –u username > > .\etc\passwd
        Remember: the username above must be an existing windows login account.
    4. Create home directories for your user
      1. In the passwd file, you will notice that the user’s home directory is set as /home/username. Change the location by editing the passwd file with notepad or any other text editor. Only edit the second last entry (/home/username), by replacing it with any directory that you wish to act as that user’s home directory, using the following syntax:
        1. /cygdrive/c/path_to_the_folder
          *cygdrive/c represents the c drive
          **c:\temp\ would be /cygdrive/c/temp
        2. ***c:\home\doe_j would be /cygdrive/c/home/doe_j
    5. Reboot the server, and verify that the OpenSSH service is running.

Our second step is to set up Secure-FTP client software at the remote location, and automate the backup job. The steps below outline this process.

  1. Download and install WINSCP from the WINSCP website.
  2. Create an account on the Windows XP Workstation with Administrative privileges that a scheduled job can run as.
  3. Log into the Workstation as this account (you will only need to do this once).
  4. Create a stored session using the IP, port, username and password assigned for access to the Secure-FTP Server. This step is required to cache information about the connection on the client’s workstation. Without it, you cannot script automatic jobs with WINSCP to your Secure-FTP server. Connect to your stored session, then disconnect, and close WINSCP.
  5. Write your batch file to automate connecting / uploading backup data to your server.
    1. winscp /console /script=backup.txt
  6. Create backup.txt, and place it in the same directory as your batch file. backup.txt is outlined in the final section of this document.
  7. Schedule your batch file to run using Windows task scheduler, as the account you’ve created to run WINSCP jobs, at the desired times and frequencies.

The third and final step is to create the text file mentioned above, which will be called upon in the batch file scheduled to run automatically, and upload data from the client to the Secure-FTP server. This is merely an example of what you can do with WINSCP, more detailed documentation can be found on the WINSCP website.

Backup.txt

*Copy and paste the following code into backup.txt


# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using the username and password set up on the Secure-FTP Server, to the address of the Secure-FTP Server
# open user:password@example.com
open username:password@192.168.0.1
# Force binary mode transfer
option transfer binary
# Upload the backup data to current working directory
put c:\example\examplefile.txt
# Disconnect
close
# Exit WinSCP
exit

*End Code, do not copy and paste this line.

The Backup.txt script file is self explanatory. Insert the username and password of the account created on the Secure-FTP Server, and the address of the Secure-FTP Server. Also edit the path near the end of the script, to the local path and file name of the data you wish to upload from the WINSCP client. The script will open WINSCP, connect to the specified Secure-FTP Server, upload the data specified, disconnect, and close WINSCP.