Need some expert advise on running scripts.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need some expert advise on running scripts.
# 1  
Old 02-20-2012
Need some expert advise on running scripts.

We have couple of scripts made for our environment (which is Oracle Virtulisation ) .

Each script is assigned a different task .
Some of the scripts are meant to run on centralized server for monitoring other Servers resource utilization such as CPU,Storage.

While some are meant to run on Server for getting server specific jobs.

Almost all scripts run using root credentials.

The script which takes output from other servers .
I have used ssh password less login using rsa keygen generated for root.

have below queries regarding the environment.
1)Will it be a good idea to make a rpm out of those scripts and maintain a version control.

2)How do i avoid root usage ?
As the environment is build on xen virtual technology and most commands only run using root.

3)Is there any other way of doing it?
# 2  
Old 02-27-2012
Tools my two cents..

here you are:

1)Will it be a good idea to make a rpm out of those scripts and maintain a version control.

- yes - packaging and centralizing software development is always a good idea.
- in your case, it only makes sense if the whole set of scripts will be deployed to all machines considered.
- otherwise you will have to group your scripts into functional units, and each one of those will then be named a different 'rpm'.

2)How do i avoid root usage ?

- if you don't need to use O.S.-administrative commands (eg. `passwd'), then you have no need for root privileges ;
- although you will have to make sure the proper access modes fit the effective UID selected to replace the root login ;

As the environment is build on xen virtual technology and most commands only run using root.

- the choice of virtualization infrastructure does not seem to impose any restriction to your scenario.

3)Is there any other way of doing it?

- this question requires elaboration ... but in any case remember the perl motto : "there's more than one way to do it" ;

HTH
_________________________________________
alexandre botao ( progsmith, polymath, ideator )
"comets never dodge".
# 3  
Old 02-27-2012
Quote:
Originally Posted by botao
- if you don't need to use O.S.-administrative commands (eg. `passwd'), then you have no need for root privileges ;
- although you will have to make sure the proper access modes fit the effective UID selected to replace the root login Smilie.
Many resource utilization tools require at least read access to system files (like /dev/kmem) and as such must be run with root privileges.

It would probably be best to run the core script/program as a unprivileged user and escalate to root access only when its needed (sudo is a great tool for this).
# 4  
Old 03-02-2012
I get many permission denied errors as i have below line in the script.

Code:
find / -name *.img*

How shall i add it in /etc/sudoer file so that i shall not be getting permission denied error?

Last edited by pinga123; 03-02-2012 at 08:00 AM..
# 5  
Old 03-02-2012
general format of the sudoers file is something like:

Quote:
userName ALL=(ALL) NOPASSWD: /path/to/command, /path/to/other-command
For example:

Quote:
testUser ALL=(ALL) NOPASSWD: /bin/mount
# 6  
Old 03-05-2012
Tools permission denied ? good !

- if you got 'permission denied' messages while doing a
Code:
$ find / ...whatever...

as an unprivileged user - then your system is at least well-behaved (it would be a sad surprise otherwise) ...

- when you descend all the way down from the top (that is - "/") , it's only natural that you stumble upon some unreadable directories ... that's the whole idea ;

- if you really want to scan you entire system without the the hassle, then you need to run this kind of `find' as root ;

- and BTW - the sudoers file can only be of help to you if you set up your 'unprivileged' user to run `find' as root ;

HTH

good luck, and success !
_______________________________________
alexandre botao (progsmith, polymath, ideator)
"comets never dodge"
Smilie
# 7  
Old 03-06-2012
Quote:
Originally Posted by botao
- and BTW - the sudoers file can only be of help to you if you set up your 'unprivileged' user to run `find' as root ;
I'd avoid opening up /bin/find to execute as root from an unprivleged account. Find can, thru the --exec option, run other commands which will also be run as root.

Your best bet here is to create a script eg /usr/local/bin/find_img_files with 600 access and root owner:
Code:
#!/bin/sh
/usr/bin/find / -name "*.img" -type f -print

And allow only this script to be run as root by the "unpriv" user:
Code:
unpriv ALL=(root) NOPASSWD: /usr/local/bin/find_img_files

This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Running scripts in bash

So I've written my first bash script.I wanted to run it from the command line, but I got an error: $ myscript.sh myscript.sh: command not found So instead I try this and it works: $ ./myscript.sh Is this how I will always need to execute it? How can I run myscript.sh without having to... (2 Replies)
Discussion started by: P.K
2 Replies

2. Shell Programming and Scripting

Optimizing the Shell Script [Expert Advise Needed]

I have prepared a shell script to find the duplicates based on the part of filename and retain latest. #!/bin/bash if ; then mkdir -p dup fi NOW=$(date +"%F-%H:%M:%S") LOGFILE="purge_duplicate_log-$NOW.log" LOGTIME=`date "+%Y-%m-%d %H:%M:%S"` echo... (6 Replies)
Discussion started by: gold2k8
6 Replies

3. Shell Programming and Scripting

running scripts in minicom

Hi, I am new to use minicom. I want script to run on minicom with username and password as automated.(Expect). please could anyone suggest the sample code for it. Thanks in advance (2 Replies)
Discussion started by: vanid
2 Replies

4. Homework & Coursework Questions

Help running scripts in 1 file.

1. The problem statement, all variables and given/known data: Running different parts of the assignment together in 1 script 2. Relevant commands, code, scripts, algorithms: awk, nawk, bash, cp, cut, echo, expr, grep, join, mkdir, paste, rm, sort, sed, test, tr, true and false. 3. The... (0 Replies)
Discussion started by: bigubosu
0 Replies

5. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

6. Shell Programming and Scripting

Running scripts via su

Hi All, Am using the below command to start my application using the root user su - bin -c "/home/bin/test/start.sh" but am getting the error becaue i have set some environment varibales in bin .profile when i execute the command start.sh by logging directly into bin account it's... (8 Replies)
Discussion started by: ravi.sri24
8 Replies

7. Shell Programming and Scripting

Running scripts unattended

Hi guys just wondering how i could make one of my scripts run unattended without the use of cron? (3 Replies)
Discussion started by: musicmancanora
3 Replies

8. Shell Programming and Scripting

Running scripts in parallel

Hi, Iam having the scripts as follows. i jus want to run those in parallel. main aim is to minimise the time for overall execution of the script. now out.txt is having 1 lac records. script1(split.sh) split -1000 out.txt splitout ls -A splitout* > filelist.txt cat filelist.txt... (6 Replies)
Discussion started by: nivas
6 Replies

9. UNIX for Dummies Questions & Answers

scripts running under different users

what command can i use to tell if a script is running under different users? (1 Reply)
Discussion started by: csnewbie
1 Replies

10. UNIX for Dummies Questions & Answers

Running scripts parallely

Hi, Posting my first query in this Forum,here's my query i want to execute 100 .sql files in unix having some code for connecting with db and executing procedures inside that,that to be run parallel like threads.want to run all the 100 .sql files simultanously. thanks in advance. (4 Replies)
Discussion started by: santho
4 Replies
Login or Register to Ask a Question