Short cut for su and cd ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Short cut for su and cd ?
# 1  
Old 03-25-2008
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?
# 2  
Old 03-25-2008
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
# 3  
Old 03-25-2008
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.
# 4  
Old 03-26-2008
su with invocation of the script as suggested works fine. Smilie

I don't have sudo in my AIX.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

3. Shell Programming and Scripting

Short circuit if

Hello everyone, just wondering if this type of if condition will execute properly. Suppose I have a script with two functions in it called abc and def: is this code valid, or is there a better way to short circuit the if statement? #! /bin/ksh93 abc(){ statement 1 using $1 statement 2... (4 Replies)
Discussion started by: gio001
4 Replies

4. OS X (Apple)

Shell Script to change desktop short cut Icon

I have installed my flash application using shell script. I have created short cut to desktop. Now i want to change the default short cut Icon. Please tell me script to change the short cut icon. ---------- Post updated at 12:54 AM ---------- Previous update was at 12:33 AM ---------- Working... (0 Replies)
Discussion started by: rohaneee
0 Replies

5. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

6. UNIX for Dummies Questions & Answers

short notice

Im getting stumped on one of my unix problems. Im a college student taking unix and for one of my assignments I am to write a few programs. I done the programs but on one of them I have to modify it by using sed instead of a while do loop. here's the while loop while do ... (2 Replies)
Discussion started by: gummiworm
2 Replies

7. Shell Programming and Scripting

short script help

how do i find out the date of the last time the system was last booted from? (8 Replies)
Discussion started by: jodders
8 Replies
Login or Register to Ask a Question