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 last test will take place at the final exam time on Tuesday, 12 December, from 1:30-3:30. It will be written as a one-hour (not 50 minute) exam, but you may have the full two hours for it. In other respects it will be very like the other tests, but comprehensive - it will emphasize Python, but cover all the topics we have seen. There is a Sample Exam, but be aware that things will have changed somewhat with the advent of ChatGPT.




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-2020 Kevin Cooper