Getting Started
Introduction
Perl IDEs
History
Advice
Tools
Mini-Tutorial
Tutorial
Code Snippets

Resources
Top Sites
More Tutorials
Books
Magazines
Articles
NewsLetters
Mailing Lists
NewsGroups
Forums
User Groups
Talk Shows
Blogs
Clothing

GBIC >> Perl >> Information Center Tutorials >> Unix

Perl Information Center Tutorials - Unix
These tutorials were written to help you get a quick, but thorough, understanding of Perl - the scope of the language as well as it's specific capabilities.

Beginners Built-In Functions     Advanced CGI Applications

Unix Web Servers
Unix is the most popular web server so familiarity with it can be helpful in maintaining a web site.

FTP Client - FileZilla
I recommend the freeware FileZilla FTP client for moving files to and from your PC and the Unix web server.

The FileZilla Help file provides an excellent tutorial, but you can also find tutorials on the web at many locations, including these:

Text File Transfer Issue
Windows and Unix text files use different characters to separate lines of text in a file. Unix uses only the LF (line feed, ASCII 10) character whereas Windows uses two characters, a CR (carriage return, ASCII 13) followed by a LF (line feed, ASCII 10).

When transferring text files between Windows and Unix machines, FileZilla can detect text files and adjust the line separator to match the requirements of the host operating system.

Binary files such as images are transferred with no modifications.

Manual Text File Conversion
A file can be manually converted from one format to the other in several ways.

  • Perl
    To convert a Windows text file to a Unix text file, use the following Perl one liner.
             perl -p -e 's/\r$//' < winfile.txt > unixfile.txt
        
    To convert a Unix text file to a Windows text file using Perl, use the following Perl one liner.
             perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt
        
  • Windows Utilities
    There are several windows utilities which can convert text files between PC and Unix formats. I suggest the simply utility u2x from James Roger.

File Permissions
For security purposes, Unix requires that each file be give permission on whether the file can be read, written, or executed. When a Perl script is transferred to the server it must have its privileges set.

Without going into too much detail, the standard permission assigned to a Perl script is 755, which simply lets visitors read and execute Perl scripts on a site. Write priveleges are withheld for obvious security reasons.

In FileZilla, simply right-click on the Perl script, select File Attributes and set the value to 755.

Telnet - Access to Unix from Home PC
It's also possible to work directly on the Unix web server from home using Telnet software which comes with all versions of Windows. Most folks do not use the technique since FTP programs provide a more convenient interface to the web server for the commands needed to manage a web site and to install Perl scripts.

When accessing a server remotely, you would use Telnet to create a connection to the server. Once connected, Telnet presents you with a window on your home PC which lets you interact with the server just as though you were sitting right in front of it. You will notice a delay between your entries and the response of the UNIX server due to the phone/modem connection, but otherwise everything is done in real time.

Below are the most common UNIX commands that you might use during a Telnet session. Remember that these are UNIX commands - not Telnet commands. Telnet is just a program that connects you to the UNIX server for remote access. You'll see that these commands are mostly associated with manipulating files on the server.

One thing to note - UNIX is case-sensitive! If you're following examples on how to use UNIX be sure to follow the case of the examples.

Common UNIX commands:

  • clear: clear screen
  • cd: change directory
  • ls: list directory content
  • pwd: print working directory (the current directory)
  • mkdir: make directory
  • rmdir: remove directory
  • chmod: change permissions
  • cp: copy a file
  • mv: move a file
  • rm: remove a file
  • man: manual (lookup documentation on a command)
  • whatis: short description of a command
  • cat: concatenation (display the contents of a file on the screen)
  • more: more (view a file a page at a time)
  • vi: vi text editor
  • pico: pico text editor