Thread: Execute Input - Shell Scipt

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    8

    Execute Input - Shell Scipt

    I am making a shell script in linux with the bash shell. I am wondering what I can do to execute the input of a user. I am trying to get the user to enter an environment variable that already exists. Then my script will execute the variable they entered.
    [code]echo "enter envir variable:"
    read Envir
    echo $Envir
    [code/]

    When I run the program and enter an environment var like "$PATH" it just echoes "$PATH" how do I get it to execute the value of $PATH, which should be:
    "bash: /usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/jdk/bin:/usr/local/ oracle/software/bin:"

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Like this?
    Code:
    $ a="echo hello"
    $ eval $a
    hello
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    8
    so its called an eval command, i'm new to this. thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 02-10-2003, 10:00 AM
  2. Replies: 4
    Last Post: 01-22-2003, 03:19 PM
  3. Problems with Shell Execute
    By golfinguy4 in forum Windows Programming
    Replies: 3
    Last Post: 12-03-2002, 12:37 PM
  4. Execute DOS Commands in C++?
    By Mike2432 in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2002, 03:09 PM
  5. Cannot Execute a C++ Program
    By Vivekasundaram in forum C++ Programming
    Replies: 2
    Last Post: 10-03-2001, 01:53 AM