Passing an environment variable as an argument

Hi,

I’d like to passe an environment variable as a argument in a shell script invoking root.
Here is what I came up with :

#!/bin/sh
for filename in *txt
do
	echo "--------> Starting process... Filename is : $filename"
	echo \"$filename\" # Displays the right filename (ie "filename.txt")
	root -l -b -q 'filemix.C(\"$filename\")' #this line causes an error
done

I get this output:

--------> Starting process... Filename is : SampleA.txt
"SampleA.txt"
Error: Symbol \"$filename\" is not defined in current scope  :0:
*** Interpreter error recovered ***
./filemix: line 6: Processing: command not found

There must be a specific syntax, I tried many quotes combinations without success.

Thank you.

Hi,
you escape too much. This should work:

#!/bin/sh for filename in *txt do echo "--------> Starting process... Filename is : $filename" echo \"$filename\" # Displays the right filename (ie "filename.txt") root -l -b -q 'filemix.C(\"'$filename'\")' #this line causes an error done
Axel.

Wow… theses quote things are tricky… I guess not for you !
Anyway it works now, thank you very much.
Cheers!