Difference between revisions of "CSC220 Homework 1 2010"
(→Problem #2) |
(→Problem #4) |
||
Line 77: | Line 77: | ||
</bluebox> | </bluebox> | ||
− | = | + | =Fun Stuff= |
+ | |||
+ | * Login to your 220a-xx account | ||
+ | * Try this at the prompt: | ||
+ | |||
+ | |||
+ | cat > dummy | ||
+ | hello there! | ||
+ | how are you? | ||
+ | Ctrl-D ''(press Control-D to simulate the End-Of-File character)'' | ||
+ | mail -s "hello from my 220a account" 220a-'''xx'''@cs.smith.edu < dummy | ||
+ | |||
+ | :'''Make sure you replace xx by your two-letter Id.''' | ||
+ | |||
+ | * Now check your 220a-xx mail by typing | ||
+ | |||
+ | mail | ||
+ | |||
+ | :at the prompt. | ||
+ | |||
+ | * You should see one message in your mailbox. It might be strange to look at your mail in something that is not a browser, but at some point in time, dealing with email was from the command line, in text mode! :-) | ||
+ | |||
+ | * Type '''1''' to see the first message in your box. Verify that its contents is what you typed above. | ||
+ | |||
+ | * I was about to ask you to write a script that would send email to all the students in 220a, but decided it would be more bothersome to everybody than useful. So I will leave this as something fun for you to consider. This is the way mass-mailing is done. With a loop, you can send email to tons of people! |
Revision as of 13:51, 14 September 2010
Contents
Problem #1
Write a script that lists all the users on grendel by year of last access to their account. The output should list all the years starting in 2005 and ending in 2010.
An example of the output could be
2005:
2006:
drwx------ 4 root root 16384 Jul 11 2006 lost+found/ (not really a user but that is ok)
drwxr-xr-x 3 flatland users 4096 Jul 11 2006 flatland/
drwxr-xr-x 7 bmikic faculty 4096 Jul 11 2006 bmikic/
drwxr-xr-x 23 102155 users 4096 Aug 3 2006 mmartin2/
2007:
drwxr-xr-x 3 root root 4096 Apr 18 2007 keterhome/
drwxr-xr-x 155 cleung users 12288 May 18 2007 snida/
drwxr-xr-x 43 zeno users 20480 Aug 14 2007 zeno/
etc...
- store your script in a file called allUsersByDate.sh and submit it as follows:
submit hw1 allUsersByDate.sh
- (For those of you who have never used our class system before, you need to be logged in your 220a-xx account to submit your programs. They get copied to the instructor's directory automatically, and time-stamped. You can submit a program as many times as you want, but be aware that each submission overwrites the previous contents of a file.)
Problem #2
- Same as Problem #1, but this time the output should be just the user's name, not the whole line showing the permissions, date, etc.
- Your output should not include the lost+found, which is not a user but just a regular directory.
- Example:
2006:
flatland/
bmikic/
mmartin2/
- Store your script in a file called allUsersByDate2.sh and submit it as follows:
submit hw1 allUsersByDate2.sh
- Hints: using the cut utility is key here. This page has useful examples.
Problem #3
- Write a script that contains all the answers to the questions in Lab #1.
- Make your script output (echo) the name of the section and the question before each output. For example
Path-Related Questions: Question 1 /Users/classes/220a/ Path-Related Questions: Question 2 100e 102b 103a 105b 107a 111b 220a 240a 352b 400b archive_old_accts.pl testd3 102a 102c 105a 105c 111a 111c 231a 249b 353a acctlist OLD
WARNING! When I execute and test your script, I will not be in your home directory, but in a different directory, somewhere in /Users/classes/220a/handin/... Therefore, make sure that you test your script by running it from a directory other than your main directory. For example, you can create a new directory in your account, copy your script there, cd to the directory, and run the script from there.
Fun Stuff
- Login to your 220a-xx account
- Try this at the prompt:
cat > dummy hello there! how are you? Ctrl-D (press Control-D to simulate the End-Of-File character) mail -s "hello from my 220a account" 220a-xx@cs.smith.edu < dummy
- Make sure you replace xx by your two-letter Id.
- Now check your 220a-xx mail by typing
- at the prompt.
- You should see one message in your mailbox. It might be strange to look at your mail in something that is not a browser, but at some point in time, dealing with email was from the command line, in text mode! :-)
- Type 1 to see the first message in your box. Verify that its contents is what you typed above.
- I was about to ask you to write a script that would send email to all the students in 220a, but decided it would be more bothersome to everybody than useful. So I will leave this as something fun for you to consider. This is the way mass-mailing is done. With a loop, you can send email to tons of people!