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
  3. We can copy the file to the /www directory by specifying an absolute path to its destination: scp 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 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
    ssh 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.

Assignment 6 is posted.

The midterm exam will take place Monday, 16 October. As with all exams, all paper notes may be used, but no electronic devices are permitted. There is a sample exam available.

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