Language dtrace
| Date: | 05/13/05 |
| Author: | Sean McGrath |
| URL: | n/a |
| Comments: | 1 |
| Info: | http://blogs.sun.com/smg |
| Score: |
#!/usr/sbin/dtrace -qs
/* Dtrace version of bottles of beer
* Written by Sean McGrath
* http://blogs.sun.com/smg
*/
BEGIN
{
n = 3;
ifor = 1;
}
tick-1sec
/!n && !ifor/
{
printf("No more bottles of beer on the wall\n\n");
printf("Time to buy more beer!\n");
exit(0);
}
tick-1sec
/n == 1 && !ifor/
{
printf("one more bottle of beer on the wall\n\n");
printf("one more bottle of beer on the wall\n");
ifor = 1;
}
tick-1sec
/n > 1 && !ifor/
{
printf("%d bottles of beer on the wall\n\n", n);
printf("%d bottles of beer on the wall\n", n);
printf("%d bottles of beeeeer . . .\n", n);
printf("Take one down, pass it around,\n");
ifor = 1;
}
tick-1sec
/ifor/
{
n--;
ifor = 0;
}
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
--Devon