Originally Posted by anurupr
i need to run a script which checks if a cd is mounted or not
It would be helpful to know what you are trying to achieve (i.e. why are you checking if it is mounted), as there may be a better solution.
That said, to do what you ask, simply put the code that you want to repeat in a 'while true' loop. Looping continuously without a break might be quite resource intensive, so you may do better to stick a sleep command into the loop, so that your check runs every x seconds/minutes. If you only want to perform the check once per minute or less, then cron may be a better solution.
The best solution may be to use udev rules so that a script is run once when a CD is mount and/or unmounted - see http://www.reactivated.net/writing_u...l#external-run
Oh, and to put the script in the background run it with an ampersand after it (&) - though it will quit when it's parent process is killed, e.g. if you close the terminal that issued the command. If you want to keep it running permanently you need to send it the NOHUP signal using kill. You may even want to make a daemon that runs on start up - by creating the relevant scripts in /etc/init.d/ and /etc/rc.d/...