LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   bash question about variables (http://www.linuxquestions.org/questions/programming-9/bash-question-about-variables-785797/)

CrossoverPsycho 01-30-2010 06:50 AM

bash question about variables
 
Heyho,

I'm trying to write a .sh script that allows me to run multiple other .sh scripts at once.

My problem occurs within a Variable:

I have set

S1 to S7 to be the name of the .sh


A="7"
B="S$A"
C="$S$A" <- and this is where my problem is

I want C to be the content of S7 till S1 but if I run this line it will of course look for the content of S and link it with the content of A.

How can I correct this?

Thank you in advance.

Cross


Edit:

WHERE="/home/X/Y/"
SH=".sh";

A="7";
B="S$A";
C="$B";

cd $WHERE;

function start
{
if [ $B != "S0" ]; then
cd $WHERE;
./"$C$SH start";
echo "$C has been started";
A=$[$A-1];
B="S$A";
C="$B";
start;
else
screen -list;
exit;
fi
}

start;
exit;

ashok.g 01-30-2010 07:02 AM

Quote:

Originally Posted by CrossoverPsycho (Post 3845941)
Heyho,

I'm trying to write a .sh script that allows me to run multiple other .sh scripts at once.

My problem occurs within a Variable:

I have set

S1 to S7 to be the name of the .sh


A="7"
B="S$A"
C="$S$A" <- and this is where my problem is

I want C to be the content of S7 till S1 but if I run this line it will of course look for the content of S and link it with the content of A.

How can I correct this?

Thank you in advance.

Cross

Why can't you assign c="S1" directly?

CrossoverPsycho 01-30-2010 07:06 AM

Because I'm using A=$[$A-1] in my code and want C to get the names from S7 to S1.

I'll edit the code into my first post ^^

macemoneta 01-30-2010 07:13 AM

Use arrays:

http://tldp.org/LDP/abs/html/arrays.html

jlinkels 01-30-2010 07:42 AM

The syntax you want to use is simply no possible. Usng arrays might be an option as suggested by macemoneta.

Check the link in my signature.

jlinkels

CrossoverPsycho 01-30-2010 08:51 AM

Thank you it works perfectly fine now ^^

pixellany 01-30-2010 09:11 AM

Moved to Programming


All times are GMT -5. The time now is 12:24 AM.