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.
- 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".
- 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
- 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
- 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
- We can do that from the
Windows machine by using
ssh myaccount@fuji.math.wsu.edu chmod 644 /www/myaccount/junk.jpg - 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 - 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).
- 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.