Department of Mathematics

Math 300: Mathematical Computing

SSH Script ICE

Your assignment: make a script that copies a file you specify to the /www directory on a Unix machine, and that then changes the permissions on that file so that it is public.

  1. Recall that you can get scp from the Math helpdesk SSH page. You should also get a program called "plink" there. Plink is a command-line version of Putty. It acts very much like the ssh command on Unix machines, and can be used in scripts. Indeed, we will save it as "ssh.exe". Save it on your "U: drive".
  2. Recall that we can copy a file from our computer to a remote computer using the command e.g. scp junk.jpg myaccount@fuji.math.wsu.edu:junk.jpg
  3. We can copy the file to the /www directory by specifying an absolute path to its destination: scp junk.jpg myaccount@fuji.math.wsu.edu:/www/myaccount/junk.jpg
  4. We can change the permissions on the file so that your group and others can view it by using the command chmod 644 junk.jpg
  5. We can do that from the Windows machine by using
    ssh myaccount@fuji.math.wsu.edu chmod 644 /www/myaccount/junk.jpg
  6. That's a lot of typing. If we are going to do this often, then we should make a little script that does it for us. Open a file called "push.bat" using the edit program or notepad or write, that contains the following lines:
    scp junk.jpg myaccount@fuji.math.wsu.edu:/www/myaccount/junk.jpg
    ssh myaccount@fuji.math.wsu.edu chmod 644 /www/myaccount/junk.jpg
  7. The problem with that is that it only works for the file "junk.jpg". We would like to be able to specify the file name on the command line. Thus, change "junk.jpg" in the above lines to "%1". This tells the script to replace "%1" by the first command-line argument (which we type).
  8. Now you should be able to type "push anyfile.jpg" on your Windows machine to copy any file called "anyfile.jpg" to the web directory on the Unix machine and make it public.


The "final exam" for this course will take place at 8:00 AM on Tuesday, 12 December. This will be an ordinary 50 minute test. It will be comprehensive, but weighted toward the latter half of the semester. As always, paper notes will be permitted, but no electronic devices will be allowed.




A Solution example is available for the quiz.




Assignment A is posted.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us
Copyright © 1996-2015 Kevin Cooper