LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2009, 12:24 PM   #1
gsb1bee
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
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.

anyhelp to get the script code written much appreciated. Thank you
 
Old 04-16-2009, 12:33 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,911
Blog Entries: 14

Rep: Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142
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).
 
Old 04-16-2009, 03:17 PM   #3
maresmasb
Member
 
Registered: Apr 2009
Posts: 108

Rep: Reputation: 24
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.

Last edited by Tinkster; 10-30-2010 at 03:17 PM.
 
Old 04-17-2009, 09:24 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,911
Blog Entries: 14

Rep: Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142
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.
 
Old 04-18-2009, 07:59 AM   #5
gsb1bee
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 04-18-2009, 10:53 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,990

Rep: Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316
Quote:
Originally Posted by gsb1bee View Post
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...
 
Old 04-18-2009, 01:17 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by gsb1bee View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with shell script john smith Linux - Newbie 4 03-14-2009 06:03 PM
shell script problem bondoq Linux - Newbie 6 07-03-2006 02:45 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
shell script problem steltner Programming 0 05-17-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration