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.
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.