Week 6: Web
Modern Interfaces with the Web
- Your Stanford Web Space
- 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
- 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.
- 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.
- Let's do that!
- 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
- SSH
- 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"
- 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:
- ssh [email protected]
- Replace "yourSUNetID" with your actual SUNetID
- 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.
- ssh [email protected]
- 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.
- Make your way to the WWW directory.
- 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.
- Create a file called "index.html", type in "Hello world" then save and close the file.
- Open up a browser and go to: http://stanford.edu/~yourSUNetID
- FTP Clients
- 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.
- Download Cyberduck onto your local machine
- Go to: https://cyberduck.io/
-
Install the Windows or macOS version
-
-
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:
-
In the drop-down menu, select SFTP (SSH File Transfer Protocol)
-
Server: myth.stanford.edu
-
Username: yourSUNetID
-
Password: yourLoginPassword
-
Don't worry about the other settings. Click Connect!
-
-
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.
- Go to: https://cyberduck.io/
-
OPTIONAL: Install Sublime
-
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:
-
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.
-
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
-
If that command didn't work for you, check out these pages:
-
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.
-
Now you can call the Sublime application just like you would vim or emacs like this:
-
subl index.html
-
This will create/open a file called index.html for editing
-
-
-
-