Week 6: Web

Modern Interfaces with the Web

  1. Your Stanford Web Space
    1. Did you know that you have web space on Stanford's servers? To see what's in your space, using your SUNetID, type in the URL http://stanford.edu/~yourSUNetID
      • Be sure to replace "yourSUNetID" with your actual SUNetID
      • Yes, the "~" is necessary
    2. You might just see a listing of things because your web space hasn't been configured yet. But, you can actually set up a personal profile page on here so that you have an official online presence.
    3. If you ssh via the Terminal into a myth or corn machine, you can manipulate the files that you saw in the listings. When you go to your web space, files will be served out of your WWW directory. If you create a file called index.html and place it into that folder, the next time you visit your web space, that file should be displayed on your browser.
    4. Let's do that!
  2. SSH
    1. According to Wikipedia, "Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote command-line login, remote command execution, and other secure network servicesbetween two networked computers"
    2. What this means is that you can access and use the Stanford computers (or any network computer) as if they were your local computer. There are two computer clusters most people usually access: Myth and Corn. You've been using the Terminal to interact with your local computer. You can use it to interact with the computers in the Myth or Corn clusters in the same way. Open up the Terminal and try this command:
      1. ssh [email protected]
        1. Replace "yourSUNetID" with your actual SUNetID
        2. You could also have used "corn" instead of "myth". These two clusters ARE different in their setup and usage, but for our purposes either one is fine.
    3. Now you're in! You have found the contents of your AFS space, provided by Stanford. You can use the shell commands such as ls, cd, mkdir, etc just like we've been doing all quarter. You can run vim or emacs to edit files or run scripts as well. The shell that you're using probably won't be the same as the one you've been used to. Type in the command "echo $SHELL" without the quotes to see which shell you're using.
    4. Make your way to the WWW directory.
      1. If this is your first time here, there's probably not much content. As previously mentioned, if you make an "index.html" file then navigate to your web space with the browser, you can view that file. We'll do that here.
      2. Create a file called "index.html", type in "Hello world" then save and close the file.
      3. Open up a browser and go to: http://stanford.edu/~yourSUNetID
  3. FTP Clients
    1. Interacting with a remote server via the shell is a very useful skill to have. However, it's not as familiar as a graphical user interface and that's where an FTP client comes in. According to Wikipedia, "File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one host to another host over a TCP-based network, such as the Internet". An FTP client is a software package that provides that transfer protocol, usually in a GUI form. We're going to get set up with one of those so that you can interact with a server via the shell and a GUI-based application. For most people, this will be easier than creating/editing files over SSH.
    2. Download Cyberduck onto your local machine
      1. Go to: https://cyberduck.io/
        1. Install the Windows or macOS version

      2. Once you've got Cyberduck up and running, try getting access to your AFS space. Open up Cyberduck and select Open Connection in the upper right corner:

        1. In the drop-down menu, select SFTP (SSH File Transfer Protocol)

        2. Server: myth.stanford.edu

        3. Username: yourSUNetID

        4. Password: yourLoginPassword

        5. Don't worry about the other settings. Click Connect!

      3. You can navigate around with the GUI on your AFS space just as you would on your local machine. You can also edit files with the local text editors on your machine! So if you weren't a big fan of vim or emacs, right click on a file and choose "Edit with" and select your editor of choice. Remember, FTP clients only transfer files. If you want to execute anything, use the shell.

  4. OPTIONAL: ​​Install Sublime

    1. While we love vim and emacs, newer text editors have made great advances in convenience, organization, and ease of use. Sublime is a popular text editor that offers great functionality so we'll be exploring it here. The download site is:

      1. http://www.sublimetext.com/3

    2. You can use Sublime in conjunction with Cyberduck to edit files by right clicking on a file and then selecting Sublime as your text editor. You can also make Sublime your default text editor so that you don't have to right click a file every time. You can do this by selecting Cyberduck > Preferences > Editor and choosing Sublime from the dropdown menu. 

    3. Sublime is much more of what you're accustomed to, huh? If you love it so much, you can also use Sublime on the shell on your local machine (i.e. not in your myth/corn shell) by installing the command line tools. Type in the command:

      sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

      1. If that command didn't work for you, check out these pages:

        1. http://www.sublimetext.com/docs/3/osx_command_line.html

        2. http://stackoverflow.com/questions/10196449/installing-sublime-texts-com...

      2. What this does is create a soft link in your bin directory to the binary in the Sublime directory. This means that whenever you type in the command "subl" the shell will look for the binary in the /bin directory, find the soft link to the Sublime directory and execute the binary in there instead. 

      3. Now you can call the Sublime application just like you would vim or emacs like this:

        1. subl index.html

          1. This will create/open a file called index.html for editing