Shell script to execute commands in individual users' home directories

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to execute commands in individual users' home directories
# 1  
Old 11-03-2009
Shell script to execute commands in individual users' home directories


I am trying to write a shell script which execute certain commands within certain folders in each user's home directories

I started off with a bash script -
#!/bin/csh -f
su -l cvsusr1
cvs -d /home/cvsadm/repository status

But the shell script finishes immediately after executing the switch command su.

Please suggest how I can proceed.


Last edited by pludi; 11-03-2009 at 09:42 AM.. Reason: code tags, please...
# 2  
Old 11-03-2009
You know that this isn't a bash shell script, but a C shell script?

Aside from that, as soon as you run
su -l <user>

the users shell is executed as a login shell, which means it's in interactive mode, and won't exit until told to do so. If you want to run a command as another user, use
su -l <user> -c <command>

This will start a login shell for the specified user, and pass the command to it to run. The shell will then exit afterwards. If you need to run more than one command, put them into a separate script and run that via su.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write a UNIX script to send a mail to the respective individual users about their groups?

Hi Team, I got a requirement to send a mail to the individual users of a unix server about their respective groups. can some one help me to provide the script as I am unable to write that. I tried with below lines but I come out with errors. cat /etc/passwd | awk -F':' '{ print $1}' |... (6 Replies)
Discussion started by: harshabag
6 Replies

2. Shell Programming and Scripting

How to execute application commands with shell script?

Hi Friends, We have a application "getstatus" which needs to run on application prompt. But it is not working with shell script. Example: Unix Root Prompt# execute "crp" to go to application prompt CRP>getstatus displays output of app health CRP>exit Unix Root Prompt# Script , which... (2 Replies)
Discussion started by: suresh3566
2 Replies

3. Shell Programming and Scripting

Shell script help to execute ssh remote commands

Hi, The below command is not giving me the count , Can somebody help me in re-writing this pls . Proc_Exist=`ssh -q -o "BatchMode=yes" -o "PasswordAuthentication=no" $OAUSER@${Primary_Node} ps -ef | grep -v grep | grep "${ICM_Proc}" |wc -l ` Also the same problem with below... (13 Replies)
Discussion started by: Y.balakrishna
13 Replies

4. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

5. Shell Programming and Scripting

Shell: How to execute commands from another file?

I made a configuration file for my shell script in that all the values that the shell scipt needs, are defined, but I don't know how to let the shell script use those defined variables. Thank you for your help :) (3 Replies)
Discussion started by: Alkali
3 Replies

6. Shell Programming and Scripting

how do execute "vi" commands in shell script?

Hi All, I need to execute the following "vi" commands in my script. How can I do that?? pls help me.... 1. escape (escape mode) 2. gg (goto first line) 3. shift+v (visual mode) 4. shift+g (goto to last line) 5. = (alinment) Thanks in advance, Saravana (3 Replies)
Discussion started by: askumarece
3 Replies

7. Shell Programming and Scripting

execute shell commands with in sftp

Hi All, Please let me know how do I execute some of the shell commands like cat, find ,grep within sftp. Any help in this regard would be greatly appreciated. Thanks, (5 Replies)
Discussion started by: tommy1
5 Replies

8. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

9. AIX

HACMP users home directories

What would be the best approach to configure one external /home f/s in simple two node config and have concurrent access ? (1 Reply)
Discussion started by: zz2kzq
1 Replies

10. Shell Programming and Scripting

how to execute shell commands in awk script?

Greetings Friends, Suppose I wish to invoke some shell level commands inside an awk script how to do that? say I wish to use : "wc" on a record to count number of characters in a record Any clues? Thanks, Rishi (1 Reply)
Discussion started by: RishiPahuja
1 Replies
Login or Register to Ask a Question