Sponsored Content
Top Forums Shell Programming and Scripting Script for running root based C++ code Post 302704841 by nrjrasaxena on Monday 24th of September 2012 09:39:43 AM
Old 09-24-2012
Hi,
It is working. I found a typo..:P :P

Thanks Smilie

---------- Post updated 2012-09-24 at 08:39 AM ---------- Previous update was 2012-09-23 at 04:06 PM ----------

Hi Corona,
I wrote a complete script to fulfill my requirement [1]. It seems that I am making some mistake. It is throwing following error:
Code:
  Mon Sep 24 15:34:08 CEST 2012
./DataMC.sh: line 55: syntax error near unexpected token `exit'
./DataMC.sh: line 55: `    exit 0'

I guess, root based application does not need "exit 0", but then how shall I exit it.

Thanks

[1]
Code:
  #!/bin/bash 
date

FILENAME=$1

usage () {
    echo "Script to Run TwoTrees Function"
    echo "      ==Possible options=="
    echo "  loop    - For making DataMcPlot"
    echo "  pileup  - For PU plot"
    echo "  vtx     - For Vtx plot (Normazed to Unity w/o selection)"
    echo "  help                  - shows this help"
    echo "Example:   ./DataMC.sh option"
}

#For Running Loop()
RunLoop() {
root -l <<EOF
.L  TwoTrees.C++
TwoTrees t  
t.Loop()
.q 
EOF
}

#ForMakingPU 
MakePU() {
root -l <<EOF
.L  TwoTrees.C++                                                                                                                                     TwoTrees t
t.ToCheckPUReweight() 
EOF
}

#ForMakingVtx
MakeVtx() {
    root -l <<EOF
.L TwoTrees.C++
TwoTrees t
t.ToCheckVtx()
EOF
}

if [ $# -lt 1 ]; then
    usage
    exit 1
fi

if [ $1 = "help" ]; then
    usage
    exit 0

#For DataMC match
elif [ "$1" = "loop" ]; then
    RunLoop()
    exit 1

#For PU plot [normalized to unity && w/o selection]
elif [ "$1" = "pileup" ]; then
    MakePU()
    exit 0

#For vtx plot [normalized to unity && w/o selection]
elif [ "$1" = "vtx" ]; then
    MakeVtx()
    exit 0
fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

All, I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
Discussion started by: bubba112557
2 Replies

2. Shell Programming and Scripting

Running a command or script as root

I'm writing an application (Progress language) that needs to: 1) load the contents of a cron table into the Progress application; 2) display this information in a human manner and allow a select group of people to update it (these people are logged in as themselves, not as root); 3) save... (3 Replies)
Discussion started by: rm-r
3 Replies

3. Shell Programming and Scripting

As root , running script as different user with su - problem

Dear All I am running into a situation where I am running a script as another user lets say oracle using su command as below, and the script fails because the .profile of oracle is not executed so the environment variables are not set. cat /etc/passwd | grep oracle... (4 Replies)
Discussion started by: dbsupp
4 Replies

4. Cybersecurity

Running script through SSH as root

Hi all, I have a situation where I have a shell script that I need to run remotely on multiple *nix machines via SSH. Unfortunately, some of the commands in it require root access. I know that best practices for ssh entail configuring it so that the root account cannot log in, you need to... (4 Replies)
Discussion started by: irinotecan
4 Replies

5. Shell Programming and Scripting

Issue running script as root

1) Environment:Red Hat Linux, bash shell Script to be run owned by user :myUser Home environment of myUser: pathto/home 2) ESP agent with root access will run JobXXX.sh su - myUser -c "/pathto/home/bin/script.sh" where script.sh has some echo statements and an exit statement in the end... (4 Replies)
Discussion started by: cj09
4 Replies

6. UNIX and Linux Applications

Getting error code when running the script 2 (RC)2

hi All, we have a script to remove the files from particular path,when we tryingto run manually the script went to success and removed the files but the same script which is running by other team it got failed and giving the error "2 (RC)2 "..what is the cause of the failure..and we passing the... (2 Replies)
Discussion started by: nagavenkatesh
2 Replies

7. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

8. Shell Programming and Scripting

Running a script as root but with different users inside

Hi All, my script.sh has the below lines, and i need to run the script as root or wam. please tell me if this will work #!/bin/bash sudo -t wam /usr/local/wam/stopwam -r ------- this needs run as wam user /usr/local/web/stopweb -a --- this needs to run as... (18 Replies)
Discussion started by: nanz143
18 Replies

9. Shell Programming and Scripting

Root running a script calling to scp using user "xyz" is not authenticating!

Close duplicate thread. (0 Replies)
Discussion started by: denissi
0 Replies

10. Programming

Running a script as root in the script

hi all, i think i have got the solution for this but want to run it past you guys first when i run a script sometimes its necassary to sudo to root so it can create users, chmod etc etc, the normal way for me doing this is just to simply run the script as root but i have created a user... (11 Replies)
Discussion started by: robertkwild
11 Replies
adt-virt-chroot(1)					     Linux Programmer's Manual						adt-virt-chroot(1)

NAME
adt-virt-chroot - autopkgtest virtualisation server using a chroot SYNOPSYS
adt-virt-chroot [options] =[chroot-name] adt-virt-chroot [options] [-rgain-root-cmd] /path/to/chroot DESCRIPTION
adt-virt-chroot provides an autopkgtest virtualisation server using a chroot install (or similar). Normally adt-virt-chroot will be invoked by adt-run. The chroot to use must be specified. If it starts with a = character then it is taken to be a chroot name known to dchroot(8). Otherwise it must start with a / and will be taken to an absolute path. OPTIONS
--gain-root|-r gain-root-cmd Specifies that adt-virt-chroot can become root (on the host) by prefixing its commands with gain-root-cmd. The command may consist of several words separated by whitespace, in which case words other than the first are supplied as additional arguments to the com- mand; other shell (or other) metacharacters in gain-root-cmd are not interpreted or modified by adt-virt-chroot. The actual command to be run as root, and its arguments, are supplied as additional (separate) arguments to gain-root-cmd. Root privilege is needed, to successfully run chroot(8), if the chroot to use is specified as an absolute path. The default is not to take any special action when root will be needed, in which case for an absolute path chroot, adt-virt-chroot must be started as root. -d | --debug Enables debugging output. Probably not hugely interesting. INPUT, OUTPUT AND EXIT STATUS The behaviour of adt-virt-chroot is as described by the AutomatedTesting virtualisation regime specification. SEE ALSO
adt-run(1), adt-virt-null(1), adt-virt-xenlvm(1), /usr/share/doc/autopkgtest/. AUTHORS AND COPYRIGHT
This manpage is part of autopkgtest, a tool for testing Debian binary packages. autopkgtest is Copyright (C) 2006-2007 Canonical Ltd and others. See /usr/share/doc/autopkgtest/CREDITS for the list of contributors and full copying conditions. autopkgtest 2007 adt-virt-chroot(1)
All times are GMT -4. The time now is 11:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy