#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    22
    Rep Power
    0

    Exporting script value


    I have my folder structure as below.

    Code:
    +application
    |_root -------------------1
       \_shellscript--------------2
    As per my requirement, I have to create a property file called path.properties at root level (1) and hence set a path. So I created the properties file with below property.

    Code:
    EXPORT SCRIPTHOME= \application\root\shellscript
    Now, I have to use this SCRIPTHOME in shell script found in shellscript folder.

    TEST.sh in shellscript folder has below content.

    Code:
    echo $SCRIPTHOME
    As a output I am getting empty value. Please let me know..If am doing something wrong here.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Where are you doing that EXPORT? If you are setting a shell environment variable I think you want to use export (lower case).
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    22
    Rep Power
    0
    Thanks Simon.

    I changed from EXPORT to export in path.properties file as below

    Code:
    export SCRIPTHOME= \application\root\shellscript
    Then I tried to execute the script TEST.sh..still am getting blank value.

    Sorry..looks like am asking very basic questions..that is only because I am new to scripting.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    22
    Rep Power
    0
    Please correct me..
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    I do believe that space is critical and the backslashes are not doing what you'd like.
    Try it like
    Code:
    export SCRIPTHOME="\\application\\root\\shellscript"
    or more likely you wanted
    Code:
    export SCRIPTHOME="/application/root/shellscript"
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Ok, a bit more clarification needed!
    You have two files, a script file and a properties file. The properties file contains the export statement and the script file, references the variable (SCRIPTHOME) that would be created by the properties file - your example is using it in an echo command.

    The issue is getting one into the other ... as it stands just running the script file will avail you nothing, the export command in the properties file needs to have been sourced (a special kind of execution) so that the variable is present within your current shell. You can do that a few ways: have your .profile (or .bashrc, etc.) file of your user source the property file, or have your script do it. To source a file all you need to is:
    Code:
    . /path/to/property.file
    Note that starts with dot space.
    And as L7sqr says, the space following the = should be dropped.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo