#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    under a rock
    Posts
    54
    Rep Power
    12

    executing variables in ksh script?


    In a ksh script on an AIX box running a jillion oracle database processes, I'm setting a variable to one of two possible arguments, depending on cmd line arguments.

    FINDIT="ps -ef | grep oracle | grep DBexport | grep rshrc"
    -or-
    FINDIT="ps -ef | grep oracle | grep prod | grep runback"

    I want to have a way to execute the command list defined by the variable $FINDIT later in the script, putting the result in another variable. Any ideas how?

    Things I have tried:
    1. The straightforward RESULT=`$FINDIT`
    (I get a usage on ps)

    2. Putting the list in braces gives me bad substitution
    FINDIT=${list}

    3. exec is not on the system.

    With either of the possible values of $FINDIT, if I execute them on the command line, there is no problem. What am I doing wrong?

    Thanks,
    -zedmelon
    Mother says my .sig can beat up your .sig.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    under a rock
    Posts
    54
    Rep Power
    12

    depressing update...


    I thought I'd found the answer in a post by M.Hirsch on this page here:
    http://forums.devshed.com/t74294/s.html

    RESULT=`echo -e "$FINDIT"`
    only puts this into the variable $RESULT:
    "-e $FINDIT"

    :(

    slash me grows despondent...
    Mother says my .sig can beat up your .sig.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    RESULT=`eval $FINDIT`

    Comments on this post

    • zedmelon disagrees
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    under a rock
    Posts
    54
    Rep Power
    12

    THANKS!


    M.Hirsch...

    That worked on the command line. I'm betting it'll work in the script as well. Of course, this is monitoring a process that runs 1/week, so I'll confirm next Tuesday...
    :(

    Thanks again; I appreciate the help.

    -zedmelon
    Mother says my .sig can beat up your .sig.

IMN logo majestic logo threadwatch logo seochat tools logo