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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
short notice gummiworm UNIX for Dummies Questions & Answers 2 03-24-2006 01:46 AM
cdrom, short file name MuellerUrs SUN Solaris 3 01-22-2006 11:45 AM
short script help jodders Shell Programming and Scripting 8 02-17-2004 07:19 AM
short banner RoMaGo UNIX for Dummies Questions & Answers 2 03-25-2003 07:06 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 155
Short cut for su and cd ?

Situation:
I've logged in as ordinary_user1;
I can su to common_dev_user;
When I su to common_dev_user, I'm taken to the HOME dir of common_dev_user;
Everytime I need to cd to a particular folder from here (say like cd /developers/ordinary_user1/code/)

This is a repetitive task (su ing and cd to the fixed path mentioned).

Requirement:
From my user id ordinary_user1, I need a short cut to su to common_dev_user and cd to this directory. Is this possible?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Sep 2007
Posts: 13
First of all, "su" doesn't ordinarily change your directory - "su -" does. Check "man su"..

But you may need the environment for other reasons. If so, put a shell script in common_dev_user's home directory:

#!/bin/bash
# this is "thescript"
cd /wherever-you-like
bash

Then invoke the su like this:

su - common_dev_user ./thescript

That causes them to run "thescript" in their home directory which cd's to where you want and starts another shell.

Have you thought about using "sudo" instead for whatever it is you need to do? Using sudo
Reply With Quote
  #3 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 155
Thanks Tony, for the direction. I'll do further research and post my findings tomorrow.

By the way, I'm using "su -" to switch user.
Reply With Quote
  #4 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 155
su with invocation of the script as suggested works fine.

I don't have sudo in my AIX.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0