Results 1 to 2 of 2

Thread: General shell script help - variable assignment

  1. #1
    Join Date
    May 2006
    Beans
    53

    General shell script help - variable assignment

    Hello Everyone,

    I am up and running in Amazons EC2, and I have installed and configured the ec2 scripting tools.

    The following command extracts the Public DNS from the indicated running instance:

    ec2-describe-instances i-XXXXXXXX |grep INSTANCE|cut -f4

    Results:

    ec2-XX-XX-XXX-XXX.compute-1.amazonaws.com

    I would like to assign this result to a variable, however, all my attemps result in the following error regardless of how I use quotes:

    PDNS=ec2-describe-instances i-XXXXXXXX |grep INSTANCE|cut -f4

    Results:

    i-XXXXXXXX: command not found

    Is there a default $Variable that gets set with the results of the last command? If not, how can I set the results of the command mentioned above to a variable?

    Thanks in advance!
    Last edited by OBI_Ron; July 23rd, 2011 at 06:25 PM. Reason: SCHPELLING ERROR

  2. #2
    Join Date
    May 2006
    Beans
    53

    Re: General shell script help - variable assignment

    Got it!

    I needed to use the `(lower case ~(tilde)).The following line worked:

    PDNS=`ec2-describe-instances i-XXXXXXXX |grep INSTANCE|cut -f4`

    echo $PDNS
    ec2-XXX-XX-XXX-XXX.compute-1.amazonaws.com

    If you are going to use it to connect via ssh, you mihgt set it as follows:
    PDNS=user@`ec2-describe-instances i-XXXXXXXX |grep INSTANCE|cut -f4`
    Last edited by OBI_Ron; July 23rd, 2011 at 06:52 PM.

Tags for this Thread

Bookmarks

Posting Permissions

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