The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do execute "vi" commands in shell script? askumarece Shell Programming and Scripting 3 06-11-2009 06:01 AM
batch shell script to zip individual files in directory - help wingchun22 Shell Programming and Scripting 7 03-08-2009 07:37 PM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 01:51 AM
HACMP users home directories zz2kzq AIX 1 02-21-2006 03:22 PM
how to execute shell commands in awk script? RishiPahuja Shell Programming and Scripting 1 09-02-2005 10:37 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
rupa_lahiri rupa_lahiri is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 1
Shell script to execute commands in individual users' home directories

Hi,

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 -

Code:
#!/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.

Regards,
Rupa

Last edited by pludi; 4 Weeks Ago at 08:42 AM.. Reason: code tags, please...
  #2 (permalink)  
Old 4 Weeks Ago
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,949
You know that this isn't a bash shell script, but a C shell script?

Aside from that, as soon as you run
Code:
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
Code:
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.
Reply

Bookmarks

Tags
shell scripting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0