LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script problem (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-problem-719622/)

gsb1bee 04-16-2009 12:24 PM

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

MensaWater 04-16-2009 12:33 PM

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).

maresmasb 04-16-2009 03:17 PM

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.

MensaWater 04-17-2009 09:24 AM

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.

gsb1bee 04-18-2009 07:59 AM

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.

TB0ne 04-18-2009 10:53 AM

Quote:

Originally Posted by gsb1bee (Post 3513151)
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.

Sorry, I don't think anyone is going to volunteer to do your work for you. There are many bash scripting tutorials out on the net, that can point you in the right direction.

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...

pixellany 04-18-2009 01:17 PM

Quote:

Originally Posted by gsb1bee (Post 3513151)
but please can you write a script for me

You just set off the "homework alarm". We are here to give tips and hints--sometimes someone will get into it and write some code, but that is not what you should be expecting.

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.