gigant0r
August 8th, 2012, 06:08 PM
Hi,
Thanks for looking at my question! :)
So, I know that Bash is an untyped system, and I was playing around with a script to switch VT's (I know I can use the CTRL ALT's, but it was more of " i'm bored lets try something.." )
Below is the script:
currentterm=$(fgconsole)
echo "Your Current Console is ${currentterm}"
echo " "
echo " "
echo " Which Console Would You Like To Teleport Two? : "
read connum
echo " "
echo "Very Well... Gating to ${connum}"
declare -i param
param=connum
chvt ${param}The script works fine, but when I first wrote it, I was trying to do a chvt ${connum} which would result in a command error, as it received a string. Now I know that bash is an untyped language for the most part, so I did a declare -i connum initially after that which didn't change anything. I finally fixed the problem by swapping the value to an already declared integer value param, as seen in the code above.
My question is, is this the most efficient way to solve this, or is there another? I've been working on scripting more lately, because I feel it is an area I'm not the best in. So any information you can give me would be helpful.
Thanks in advance! :)
Thanks for looking at my question! :)
So, I know that Bash is an untyped system, and I was playing around with a script to switch VT's (I know I can use the CTRL ALT's, but it was more of " i'm bored lets try something.." )
Below is the script:
currentterm=$(fgconsole)
echo "Your Current Console is ${currentterm}"
echo " "
echo " "
echo " Which Console Would You Like To Teleport Two? : "
read connum
echo " "
echo "Very Well... Gating to ${connum}"
declare -i param
param=connum
chvt ${param}The script works fine, but when I first wrote it, I was trying to do a chvt ${connum} which would result in a command error, as it received a string. Now I know that bash is an untyped language for the most part, so I did a declare -i connum initially after that which didn't change anything. I finally fixed the problem by swapping the value to an already declared integer value param, as seen in the code above.
My question is, is this the most efficient way to solve this, or is there another? I've been working on scripting more lately, because I feel it is an area I'm not the best in. So any information you can give me would be helpful.
Thanks in advance! :)