shell script problem
Hi everyone,
i have developed a menu drive program in bash.Now i am gonaa try the concept further i.e. the application has its own status report login enabling the programme to run without giving operator access to shell. advancing the concept further the programme could be developed so that it is able to run with a ‘none interactive flag’ – enabling it’s execution to be automated with the resultant file e-mailed to a user perhaps once a day or once a week. well i am completely blank with enabling programme to run without giving operator access to shell.:confused: anyhelp to get the script code written much appreciated. Thank you |
You could try making the script itself the "shell" in the passwd file (that is replace /bin/bash with the full path to the script). To do that you need to insure all the variable and paths the script needs are included in the script as it won't be running in a shell so won't inherit any of those things.
Insure the script has an interpreter line like: #!/bin/bash at the beginning so it know to run the script as bash (or replace with your preferred shell). Insure it has PATH= like PATH=/bin:/usr/bin:<sometotherdir> so it knows where to find all the commands it uses. (e.g. ls, cp, more, mailx etc...). You can figure out where all the commands you use live by typing "which command". The PATH should have all directories that are used by any of the commands (but only once - you only need /bin once if both ls and cp are in /bin). Insure it has any other variables you are relying on in the script defined if they are normally provided by .bashrc or .bash_profile (or .profile if ksh for example). If all that doesn't work then you can just modify the .bashrc to have an "exec <script>" line at the end. This tells it to replace the current process (the shell) with the command after exec (the script). |
I have found jlightner's concept very cool (I should try something like that someday), but in the current case this sounds like a job for a plain and simple cron job. No shell access, automated execution, timed as requested.
|
OK - I misunderstood - I thought you wanted the user to login to start the program. If you don't need them to login then cron is certainly the way to go.
Note that cron like the other idea requires that the script contain all the variables including paths as it also does not inherit and environment from user. |
Hi , Thanxx for reply
but i never used CRON and its not been allowed to use crontab but please can you write a script for me so that I can get atleast a start with. I am completely blank writing the script for this. Much Appreciated. |
Quote:
Post what you've written, and we'll help. If you'd like someone to write programs for you, those people are called 'consultants', and get paid... |
Quote:
The first thing to do (other than reading the documentation) is to experiment with various commands to see how they work. Only then are you ready to start building scripts. |
All times are GMT -5. The time now is 08:18 PM. |