Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: 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

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •