10-19-2011
I understand how su & sudo work.
My requirement is to be able to switch users from within the perl script, so that specific actions/commands are performed under the required account. I do not want to ssh as the required user. I need to make the connection to the box as a specific user and then run the script (or parts of it) as a different user.
I do not want to use a wrapper script or any other external method, surely there must be a way to switch users from within the script itself. I will have a subsequent requirement where I want to switch to different users multiple times so I want to be able to do it only from within the script itself.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to get the user input and execute a particular script based on the input provided.
For E.g. When I execute the script say Test.sh it should prompt "For which country I need to execute the script? (US/India)"
Based on the input as US or India from the user the execution of... (8 Replies)
Discussion started by: yoursdavinder
8 Replies
2. Shell Programming and Scripting
Hi all,
i am trying to remotely execute a script from a different server.
this is the code that i use :
#!bin/sh
pwd
(sleep 1 echo "username"
sleep 2 echo "pwd"
sleep 2 echo "cd /path/to/file"
if
then
echo "script1.sh"
echo "mailx -s "Task Executed"... (1 Reply)
Discussion started by: sais
1 Replies
3. Shell Programming and Scripting
I am using festival speech synthesis system and I would like to allow user input in a browser. This will be taken by a php page which is then supposed to pass the input text to a perl script. The perl script should pass this text to the festival engine by executing a unix command. this in turn... (2 Replies)
Discussion started by: wairimus
2 Replies
4. Shell Programming and Scripting
Hi all
I wrote a script to execute a script on several remote hosts, but somehow during the execution of the local script, ssh can't come back from the remote host, so that causes my local script hanging... I use the below command to do the job in the local script, any idea?
ssh... (12 Replies)
Discussion started by: bzylg
12 Replies
5. Shell Programming and Scripting
does anyone know how can i execute a script which i locally run as " . /etc/local/host/src.srvr -D ."
need to execute above command in rexec command. if i put the command as it is it does not run. Sorry but i am naive in scripting. Thanks
rexec sgplqim -l vau -n '
' (0 Replies)
Discussion started by: NK4U
0 Replies
6. Shell Programming and Scripting
How to see the output from remote server during execution of a script ?
I am executing a script (ls) from machine 1 but the o/p should be displayed in machine 2. Can I achieve this ?
Example:-
Machine 1:-
# ls
Machine 2:- (console)
file1 file2 file 3
dir1 dir2 (0 Replies)
Discussion started by: frintocf
0 Replies
7. Solaris
So I have a scriptlet called solaris_command:
for i in \
server1 server2 server3
do
echo $i
ssh $i $1
echo ""
done
I then use that as a command in multiple scripts to allow for data gathering for all virtual hosts in the environment thusly:
solaris_command "cat... (3 Replies)
Discussion started by: os2mac
3 Replies
8. Shell Programming and Scripting
#/bin/sh
echo "enter the user name"
read $username
echo "Enter new home directory"
read $newhd
usermod -d $newhd $username ;;
error while executing :
enter the user name
Rev
Enter new home directory:
/home/58745
usermod: option requires an argument -- 'd'
Try `usermod --help' or... (2 Replies)
Discussion started by: Revanth547
2 Replies
9. Shell Programming and Scripting
Hi All ,
I'm running a script abc.sh in server "host1" shown as below :
#! /bin/bash
sh stop.sh
ssh user@$host2 "/home/user/prod_work/xyz.sh;
sh start.sh
The problem I am facing is , the control is not passed to host1 after executing the script "xyz.sh" in host2 .
... (12 Replies)
Discussion started by: Pradeep_1990
12 Replies
10. Shell Programming and Scripting
If I execute below code I am able to get string from column8 and column10 about a process.
serverA1$> ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}'
/<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs1... (12 Replies)
Discussion started by: kchinnam
12 Replies
LEARN ABOUT DEBIAN
0store-secure-add
0STORE-SECURE-ADD(1) 0STORE-SECURE-ADD(1)
NAME
0store-secure-add -- add an implementation to the system cache
SYNOPSIS
0store-secure-add DIGEST
DESCRIPTION
This command imports the current directory into the system-wide shared Zero Install cache, as /var/cache/0install.net/implementa-
tions/DIGEST. This allows a program downloaded by one user to be shared with other users.
The current directory must contain a file called '.manifest' listing all the files to be added (in the format required by DIGEST), and this
file must have the given digest. If not, the import is refused. Therefore, it is only possible to add a directory to the cache if its name
matches its contents.
It is intended that it be safe to grant untrusted users permission to call this command with elevated privileges. To set this up, see
below.
SETTING UP SHARING
To enable sharing, the system administrator should follow these steps:
Create a new system user to own the cache:
adduser --system zeroinst
Create the shared directory, owned by this new user:
mkdir /var/cache/0install.net
chown zeroinst /var/cache/0install.net
Use visudo(8) to add these lines to /etc/sudoers:
Defaults>zeroinst env_reset,always_set_home
ALL ALL=(zeroinst) NOPASSWD: /usr/bin/0store-secure-add
Create a script called 0store-secure-add-helper in PATH to call it. This script must be executable and contain these two lines:
#!/bin/sh
exec sudo -S -u zeroinst /usr/bin/0store-secure-add "$@" < /dev/null
The other Zero Install programs will call this helper script automatically.
FILES
/var/cache/0install.net/implementations
System-wide Zero Install cache.
LICENSE
Copyright (C) 2009 Thomas Leonard.
You may redistribute copies of this program under the terms of the GNU Lesser General Public License.
BUGS
This program is EXPERIMENTAL. It has not been audited. Do not use it yet in security-critial environments.
The env_reset line in sudoers may not be required. sudo(1) seems to do it automatically.
If sudo let us check whether we could call a command then we could switch to using it automatically, instead of needing to add the helper
script. Currently, sudo delays for one second and writes to auth.log if we try to use this system when it hasn't been set up.
Please report bugs to the developer mailing list:
http://0install.net/support.html
AUTHOR
Zero Install was created by Thomas Leonard.
SEE ALSO
0store(1)
The Zero Install web-site:
http://0install.net
Thomas Leonard 2010 0STORE-SECURE-ADD(1)