LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-06-2007, 04:59 AM   #1
sharathkv25
Member
 
Registered: Jul 2006
Distribution: HP-UX
Posts: 46

Rep: Reputation: 15
su from root to anotehr user in script


Hi,

I am not able to print a variable.
I run this script as 'root'

Code:
#!/bin/ksh
#
su - orauser << !
. /opt/ora/env/ora-db.env
echo $ORACLE_HOME
!
I get this error
Code:
stty: : Not a typewriter
It's not printing $ORACLE_HOME.

I am able to print $ORACLE_HOME manually.

thanks
 
Old 03-06-2007, 07:10 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
why?

try su without the -
 
Old 03-06-2007, 07:32 AM   #3
sharathkv25
Member
 
Registered: Jul 2006
Distribution: HP-UX
Posts: 46

Original Poster
Rep: Reputation: 15
Sorry, did not work.

I ended by specifyinh the full path instead of using $ORACLE_HOME.
 
Old 03-06-2007, 09:48 AM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
You could do something like this also:
Code:
su orauser -c "(. /opt/ora/env/ora-db.env ; echo $ORACLE_HOME ; )" -
( opens a subshell
{ runs it in the environment

man bash
man su

Actually sudo is made for what this, rather than su
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to check root user? kushalkoolwal Programming 4 09-22-2005 12:15 AM
how to test if user is root or not in a shell script? dr_zayus69 Programming 3 08-17-2005 03:00 AM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 07:54 AM
How to change to root user within a script? bjdea1 Linux - Software 1 09-07-2004 09:58 AM
load script during boot not as user root? ziggie216 Linux - General 1 11-20-2003 11:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:37 AM.

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