Execute Input - Shell Scipt

This is a discussion on Execute Input - Shell Scipt within the Linux Programming forums, part of the Platform Specific Boards category; I am making a shell script in linux with the bash shell. I am wondering what I can do to ...

  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
    32,824
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 04:09 PM
  5. Cannot Execute a C++ Program
    By Vivekasundaram in forum C++ Programming
    Replies: 2
    Last Post: 10-03-2001, 02:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21