|
TQNYC Tutorials > Nano
Using Nano - A Text Editor
A command line editor is a text editor that can be run from a command prompt via a telnet or ssh session. It allows you to create or edit HTML, text, scripts or practically any text file. Although it is not as easy as a GUI based editor you may be used to it does afford you the luxury of being able to create and edit your site files from almost any computer in the world.
Pico and other command line editors do not write the code for you. In other words you need to know HTML. We offer a basic HTML Tutorial and there are many books and online tutorials to get you started as well.
Step 1. Connect to the server.
If you do not know how to do this check out TQNYC Telnet/SSH Tutorial.
Step 2. Create a new file.
At the prompt type the following and hit enter.
nano text.html

Now you have launched nano with a new blank file named "text.html". If you wanted to edit an existing file you would type "nano" and the name of the file. Take a second to look around at how the window has changed.

The first thing you may notice is the "GNU nano 1.2.2" in the upper left corner. GNU Nano 1.2.2 is telling you the program and it's version. Not real important but so you know.
In the center of the top bar it tells you what file you are editing.
At the bottom of the screen you should see a bunch of commands. The caret (^) signifies holding down the control key and typing the letter. For example "{cntrl} g" (^G) with display a Help file with a bunch of information about using nano. "{cntrl} x" (^X) will exit the program and return you to the prompt. "{cntrl} o" (^O) or (f3) will write or save the file to the servers harddrive.
You should see the prompt just below the "GNU nano 1.2.2" text. This is where you can begin typing.

This is certainly not a completed web page but it will do for our purposes.
Now we want to write or save the file. We do this by holding down the {ctrl} key and pressing "o" or "f3" the function key.

Notice how the screen has changed towards the bottom left. It is now asking you if you want to save this file with this name. If you do press enter. If you do not either hit {escape} or enter the name you want the file named as.

I hit enter and saved the "text.html" file and you can see at the middle bottom of the screen it says "[ Wrote 1 line ]". There was only one line in this file and nano talks in lines.
The last step is to quit nano, {ctrl} x. If everything has gone well we should be back at the command prompt.
Lynx Browser
So now we have a new HTML file (web page) in our account on the server. It is not a very robust or well formatted web page but it should open in most browsers. How can we see what it looks like?
You should be able to open a browser like Nescape or Mozilla or Internet Explorer and type the following URL into the location bar, http://www.tqnyc.org/{TEAM ID}/text.html and see the line of text you just wrote with nano.
Or you can view it from the command line. The drawback to web browsing from the command line is that it does not display images. But we can use what is called a "text browser" and see what it looks like. The text browser we have on the TQNYC server is called "lynx". It is very old and very wise. To look at your new page simply type:
lynx text.html
The screen should now be the lynx browser with your page displayed. Keep in mind this is looking at the page locally, or on the server you are telnet or ssh into. You could also see it this way.
lynx http://www.tqnyc.org/{Team ID}/text.html
However you typed it in the page in lynx should look like this.

You can see a few of the most common lynx commands at the bottom of the screen. These are activated by simply selecting the first letter, no {ctrl} needed. For example if you wanted to "Go" to "http://www.google.com" you would type "g" and then enter "http://www.google.com". Lynx will ask you what you want to do with the cookie. Simply type "a" and accept it. Now you should see the google page. You can even TAB down to the white dotted line and enter a keyword or two to search.
You may be thinking lynx is not terribly useful. But just because it cannot display images or handle HTML tables or many other layout concepts like regular GUI browsers does not make lynx worthless. Lynx is good if you only have a command line interface and want to look something up on a search engine like Google. HTML forms work and it maybe awkward but you can navigate many web sites this way. Lynx can also download things.
Lynx will display the "alt" tag text in images if entered into the web page. So if you use images as links you should enter approrpiate "Alt" tag text to help lynx users get around your site.
The text browser has been around much longer than the GUI browser and for visually impaired people the text browser is often used with text to speech software so they can navigate the web and "read" your content. Make your web pages handicapped friendly, use alt tags.
Return to the Tutorials or the TQNYC Command Line.
|