Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I've been working with Amazon's EC2 platform and I'm trying to automate some of the grunt work in a bash script. The problem is, though, that I don't know how to assign variables that I need to access the instances running in the cloud. Here's an example:
This command is describing an instance with an ID, its status, and the public DNS address. I need to be able to assign the DNS address to variable or something so I can use it in an ssh command to connect to it, like this:
ssh -i cert.pem root@[VARIABLE]
is there any way to do this or something similar in bash? If you have other methods I'd be glad to hear them as well. I really don't want to try to pick up Python or Ruby to do this. Thanks in advance!
I think this just assigns 'ec2din --simple | cut -d " " -f3' to VARIABLE. typing echo $VARIABLE just returns the command, not the output. I'll try the do while loop, but there's a new wrinkle thrown in too now. When more than one instance is started, it lists them all on separate lines, and terminated instances show up as:
Thoughts on how to get one specific address out from a list like that?
sending the output before the cut to a "grep -v terminated" will get rid of the terminated lines. What do you know about the instance you are trying to get? If you know the ID, you can replace the grep -v terminated with a grep $ID and that will get you one line.
the grep -v line worked great, but no, unfortunately, that's one of the reasons I'm having issues with this. There's no way to specify or know what an instance's ID is without pinging it with this command. As far as I know, there's not a tool that returns only the address or instance ID.