Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have several Amazon EC2 instances, running Ubuntu 10.04, with which I'd like to use Amazon's Route53. I setup a script as described in Shlomo Swidler's article, but I'm still missing something.

When the script runs, it doesn't return any output, which I initially assumed meant it ran correctly. However, when I check the DNS records using MyR53DNS, there are no entries for my instances. Here's my script:

#!/bin/tcsh -f

set root=`dirname $0`
setenv EC2_HOME /usr/lib/ec2-api-tools
setenv EC2_CERT /etc/cron.route53/ec2_x509_cert.pem
setenv EC2_PRIVATE_KEY /etc/cron.route53/ec2_x509_private.pem
setenv AWS_ACCESS_KEY_ID myaccesskeyid
setenv AWS_SECRET_ACCESS_KEY myaccesskey

/usr/bin/ec2-describe-instances | \
perl -ne '/^INSTANCE\s+(i-\S+).*?(\S+\.amazonaws\.com)/ \
and do { $dns = $2; print "$1 $dns\n" }; /^TAG.+\sShortName\s+(\S+)/ \
and print "$1 $dns\n"' | \
perl -ane 'print "$F[0] CNAME $F[1] --replace\n"' | \
xargs -n 4 /etc/cron.route53/cli53/cli53.py \
rrcreate -x 60 mydomain.com

Does anyone see a problem with this script? If its not the script, what else could be preventing my Route53 domain from being updated?

I am using the Security Groups to IP-restrict the instances. I've tried opening port 53, but that didn't seem to have an effect. Is there another port that Route53 uses?

I'd appreciate any help or guidance the Unix & Linux community can offer. Let me know if you need any further info.


Here is the results of running: tcsh -f -x /etc/cron.route53/aws-route53.sh

set root=`dirname $0`
dirname /etc/cron.route53/aws-route53.sh
setenv EC2_HOME /usr/lib/ec2-api-tools
setenv EC2_CERT /etc/cron.route53/ec2_x509_cert.pem
setenv EC2_PRIVATE_KEY /etc/cron.route53/ec2_x509_private.pem
setenv AWS_ACCESS_KEY_ID myaccesskeyid
setenv AWS_SECRET_ACCESS_KEY myaccesskey

I receive the same output whether the last 7 lines are commented or uncommented.


> cat -A  /etc/cron.route53/aws-route53.sh
#!/bin/tcsh -f$
$
set root=`dirname $0`$
setenv EC2_HOME /usr/lib/ec2-api-tools$
setenv EC2_CERT /etc/cron.route53/ec2_x509_cert.pem$
setenv EC2_PRIVATE_KEY /etc/cron.route53/ec2_x509_private.pem$
setenv AWS_ACCESS_KEY_ID myaccesskeyid$
setenv AWS_SECRET_ACCESS_KEY myaccesskey$
$
/usr/bin/ec2-describe-instances | \$
perl -ne '/^INSTANCE\s+(i-\S+).*?(\S+\.amazonaws\.com)/ \$
and do { $dns = $2; print "$1 $dns\n" }; /^TAG.+\sShortName\s+(\S+)/ \$
and print "$1 $dns\n"' | \$
perl -ane 'print "$F[0] CNAME $F[1] --replace\n"' | \$
xargs -n 4 /etc/cron.route53/cli53/cli53.py \$
rrcreate -x 60 mydomain.com

> cat /etc/cron.route53/aws-route53.sh
#!/bin/tcsh -f

set root=`dirname $0`
setenv EC2_HOME /usr/lib/ec2-api-tools
setenv EC2_CERT /etc/cron.route53/ec2_x509_cert.pem
setenv EC2_PRIVATE_KEY /etc/cron.route53/ec2_x509_private.pem
setenv AWS_ACCESS_KEY_ID myaccesskeyid
setenv AWS_SECRET_ACCESS_KEY myaccesskey

/usr/bin/ec2-describe-instances | \
perl -ne '/^INSTANCE\s+(i-\S+).*?(\S+\.amazonaws\.com)/ \
and do { $dns = $2; print "$1 $dns\n" }; /^TAG.+\sShortName\s+(\S+)/ \
and print "$1 $dns\n"' | \
perl -ane 'print "$F[0] CNAME $F[1] --replace\n"' | \
xargs -n 4 /etc/cron.route53/cli53/cli53.py \
rrcreate -x 60 mydomain.com
share|improve this question
    
There are a couple of obvious problems in your script: /user/bin should be /usr/bin, $/etc should be /etc. Did you try running the script in a terminal? Both problems would show an error message. If that's not your actual script, then copy-paste your actual script (except for the access keys of course). –  Gilles Feb 14 '11 at 20:12
    
Good point. I've re-pasted in my script above, fixing the two errors you mentioned. However, its still doing the same thing. I run it, which results in no output. Then I check the MyR53DNS, but there are still no entries for my instances. Do you see any other problems with my script? –  ks78 Feb 14 '11 at 20:30
    
@ks78: Run tcsh -f -x /path/to/your/script. This will show a trace of the commands the shell runs. Post the trace. Also make a copy of the script that stops at /usr/bin/ec2-describe-instances and post the output of that. On a separate note: I just happened to notice your edited question, but I wasn't notified of your comment. When you reply to a comment, you can use @username so that the author of the comment is notified. –  Gilles Feb 14 '11 at 21:25
    
@Gilles: I've posted the output above, at the end of my question. I get the same output when the script stops at /usr/bin/ec2-describe-instances. –  ks78 Feb 14 '11 at 21:41
    
@ks78: That's weird, the shell stops executing your script midway. Maybe there's a nonprintable character: compare the output of cat -A aws-route53.sh with cat aws-route53.sh. The only difference should be a $ at the end of each line. Is there any non-alphanumeric character in myaccesskeyid or myaccesskey? –  Gilles Feb 14 '11 at 22:08

1 Answer 1

up vote 2 down vote accepted

Aha! Your script is missing a newline at the end. Unix text files (such as scripts) are sequences of line, and each line (even the last) must be terminated by a newline.

Most modern unix tools can cope with malformed text files, but tcsh doesn't count as modern: it looks like it ignores the last, unterminated, logical line (everything after the last newline that's not preceded by a backslash).

A good editor (such as Emacs or Vi(m)) automatically makes sure that csh scripts are terminated by a newline.¹ It looks like your editor is not doing the right thing, so make sure your scripts do end with a newline (cat /path/to/script must show the last script line above the next prompt, not next to it).

¹ In a really good editor, such as Emacs, this doesn't apply to other kinds of files that may legitimately be not newline-terminated.

share|improve this answer
    
I think you've solved my problem. I'm getting another error, but it looks like it has to do with a missing dependency. Once I have that fixed, I'll know for sure. Thanks again. –  ks78 Feb 14 '11 at 22:34
    
Yes, that was it. It works! Thanks for all your help. –  ks78 Feb 14 '11 at 23:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.