The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script running with "ksh" dumping core but not with "sh" simhe02 HP-UX 9 4 Weeks Ago 05:52 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 10:52 PM
How to get Find command work with a variable passing "*" value? unxuser Shell Programming and Scripting 5 08-16-2006 07:47 AM
By angle-brackets/"pipe" button doesn't work? riwa Linux 1 04-02-2006 03:43 PM
"whenever sqlerror exit 1" does not work on Linux nir_s Shell Programming and Scripting 2 09-22-2005 07:41 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-18-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Smile variables don't work for inline "su" script

My first post here...

I cannot get variables to work when using inline KSH commands on a "su" command. I have a KSH script, below, that produces my problem:

#!/usr/bin/ksh
su <user_id> <<-END
export FLD1=`echo $PWD`
pwd
echo $FLD1
echo TEST
echo $PWD
END

The script will prompt me for the user's password, and then will display the following:

Password:
/home/jkreife

TEST
/home/jkreife

Notice the "blank" line between my $HOME directory and "TEST". It should have displayed the contents of the FLD1 variable, but does not. My intention is to run a KSH script that loads an Oracle DB using an oracle admin signon, but cannot get variables to work. Can any Unix expert look at this and give me some much needed help?

Thanks!
Joe K.
Reply With Quote
Forum Sponsor
  #2  
Old 04-18-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Joekreif,
Try putting single quotes before and after the END:
su <user_id> <<-'END'
Reply With Quote
  #3  
Old 04-18-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Resolved!!!

You are a bloody genius!!! That did the trick. Thank you very much!

Joe K.
Reply With Quote
  #4  
Old 04-18-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
You are welcome, Joekreif, but this time, it was a co-worker of mine
who gave the solution.
The main thing is to get the problem resolved.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:56 AM.


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

Content Relevant URLs by vBSEO 3.2.0