If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > command set does not work!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-04, 18:56
scng scng is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
command set does not work!

Hi all,

I am trying to set an variable within the shell file, however it does not take the set. I can only set the variable in the prompt instead.

#!/usr/bin/sh

echo "set ONE=1"


output file: test.sh
$sh test.sh
Content in test.sh:
set ONE=1

--------
$echo $ONE
ONE: Underfined variable

Anyone knows why is not working? How to make it work within the script.
Thanks!

-scng
Reply With Quote
  #2 (permalink)  
Old 01-07-04, 04:04
chillies chillies is offline
Registered User
 
Join Date: Jul 2003
Location: Edinburgh
Posts: 35
Re: command set does not work!

I'm not sure what you're wanting. It seems that you run a script and test whether the environment variable is set after the script runs. This will not work - the envrionment variable has been set in a subshell.

Check out the source command or . (period) to execute commands which are contained within a script in the current shell.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On