Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-10-2012, 12:27 AM   #1
LQ Newbie
Registered: Jan 2012
Posts: 16

Rep: Reputation: Disabled
Using shell script how to switch user and change folder

Hi All,

I am new to schell script, I am trying to achieve the following with a shell script, kindly advise, thanks

1) change user say sudo su - oracle
2) the change folder to cd /sw/database
3) tail -f alert.log

Another shell for;

1) change user say sudo su - oracle
2) sqlplus '/as sysdba'
3) startup
Old 02-10-2012, 12:43 AM   #2
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
change user say sudo su - oracle
2) the change folder to cd /sw/database
3) tail -f alert.log

For the first thing, at least, you should be able to do a one-liner like so:

sudo -u oracle tail -f /sw/database/alert.log
Just put that in a script and run the script.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Shell script to change password for current user treznik Linux - General 7 09-12-2010 04:17 PM
using an shell script how to change a value in a file according to the user input badrinath_tcs Linux - Software 6 09-28-2009 07:29 PM
How do i change to super user then revert back to ordinary user ,using shell script? wrapster Solaris / OpenSolaris 6 03-18-2009 03:37 AM
How to switch user via shell script cool_anupam Linux - General 7 05-29-2008 10:01 PM
Can my shell script change the password of user ? prabhatsoni Linux - Software 1 05-27-2006 02:06 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration