A simple reminder script for beginners to shell scripting.
(Apologies for any typos.)
Well hands up those who have been in the following situation(s):-
Your partner, (in my case the missus), sees that you are messing
with your machine and says something like, "can you keep an eye
on the dinner, I am going out shopping", and you look up glazed
eyed and say, "yes dear".
Sadly you forget and the dinner is burnt...
WW III is about to start... ;oD
Own up now, c'mon hands up!
Ah yes, nearly everyone. Those with their hands down cannot be
trusted... ;oD
The wife did just that to me and that gave me an idea, the
script below...
It is a piece of code that beginners could understand as a
practical and useful starting point to learn simple shell scripting.
It is called 'reminder' and generates a seriously annoying pop-up
every 30 to 300 seconds, programmable, with a reminder text of
your choice.
As a learning tool this script contains a lot of simple shell
stuff.
Arguments, variables, conditions, for loop, while loop, launching
another script, creating the script to launch, ANSI escape codes
to name but a few...
Written on OSX 10.7.5 default shell, tested on CygWin.
I am assuming it works on Linux flavours so just change the
script yourselves and notify this thread of your modifications;
IF there are any...
If you want this to work on CygWin then read the 'while true'
section and edit as required.
This is just superb for remembering your anniversary, the wife's
birthday, etc, etc, as it is SOOOO annoying...
This version is Public Domain and will not be uploaded anywhere
else.
The much simpler original is on 'code.activestate.com' also PD.
Enjoy finding simple solutions to often very difficult problems...
LBNL, for beginners, try and add a 1 second beeping sound for the
various *NIX flavours...
Here are a couple of remarks, so it could be improved further:
1. The shebang is #!/bin/sh, so the script should conform to Posix Shell Standards and not use bash code..
2.:
should be
3.
Can be written as:
4.
$[ ... ] is deprecated bash code. It should be:
5.
should be:
6.
could be written as number=${countdown:$n:1}, but would still be bash code.
Consider using ${var%"${var#?}"} for example and vary the number of question marks...
Another option would be to replace the for loop with a case statement
7.
For security and other reasons it is best to not use the format field for uncontrolled data. So perhaps something like:
8. There should be a wait statement after the last done
This User Gave Thanks to Scrutinizer For This Post:
I will leave the existing one and post a replacement as the existing one
works in CygWin and bash does have some minor foibles on CygWin.
One thing though why do I need a wait when it will never
be reached even when Ctrl-C is pressed?
I thought that in theory every time the "xterm" window closed there
would be more than enough time for the system to catch up; I even
assumed there would be no memory leak(s)...
I had mine on all day on this machine without a hitch...
Hi Wisecracker. True, I guess. I habitually use a wait statement to wait for background processes. That way I do not have to think, when the while true loop is changed to something else in the future for example...
Hello All,
My name is vasu and I am very new to Unix scripting, i know basic commands, but now i need to write the following script, i have tried but no luck
My requirment is i am getting one our from another command as following
Used:1.8TB Advisory Quota:1.8TB aaa1
Used:4.5TB Advisory... (1 Reply)
1. The problem statement, all variables and given/known data:
An argument example:
../path/cse/lab3/remove
Right now, it's printing out all the directory and files in 'lab3'.
I want it to print out all the files in 'remove'.
I'm not sure how to do that. (I want to use a for loop)
2.... (2 Replies)
Hey, i hope someone can help me with this program.
I need to write a program in shell which will return how many times and how much time have users been logged in system between two dates. We give time as 2 dates as arguments in command line.
Example:
$ nameofprogram 27/04 06/05
... (1 Reply)
Hello,
I want to find the "IP-OF-SERVER" in /etc/squid/squid.conf And replace it with The IP of server.
I know this command returns the IP of server :
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
And I can replace with sed. :
sed -i... (4 Replies)
Hello Friends,
I am writing a shell script which will grab a file if it exists and copies it to another folder and will append with current date. I have written but gives me error, plz help:
--------------------------------------------
#!/usr/bin/sh
source=/home/dev4rice/naveen/test1... (4 Replies)
CPAN provide xml::simple module which can be used to generate XML files.
can i use this module in shell scripting? how? plzz give me an example to generate xml file using this module . you can also use some other module..
BUT SHELL SCRIPTING SHOULD ONLY BE USED (4 Replies)
Hi,
I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram
I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Hi,
I need of a simple shell script to launch a perl script.
The complet path of the script is:
/export/home/x2693/project/v02/appliancemanagement.pl (2 Replies)
Hi,
I am new to unix as well as shell programming.
Any body can provide me a simple shell script which should copy/transfer/fetch a file(using FTP)from remote server to local system.and it should log the details when it was fetched.If there is any error,the error msg should log in log... (1 Reply)