ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
You need to set $mypcp before setting $monitor (you can set a variable several times in a script if you wish) since if you do it the other way around, $mypcp will not contain anything when you try to set $monitor to the contents of $mypcp...did that make any sense?
I don't think that's exactly what sdandeker wanted. Your solution would make the values of $monitor and $mypcp identical. It seems the result should be that the value of one variable becomes the _name_ of the other variable.
Thinking about it is beginning to make my head spin though (not enough coffee)
Mik, you think he wants $monitor to contain the string "$mypcp", not at all related to the variable $mypcp? If so then monitor=\$mypcp; echo $monitor would return the string $mypcp and not the contents of the actual variable $mypcp.
I've had my share of coffee today. Not enough beer, perhaps?
SO... I want to be able to do several things in my program by using the monitor variable to change the way the program behaves. The first time the loop runs, it should ping the 1st IP and put the result in a file which has "mypc1" in its name. I then use some grep to pull the average ping value and eventually want to assign this result to a variable which contains the name "mypc1".
This will basically allow me to use a for loop changing the filenames and variable names instead of writing the same code 3 times with different names.