Variable not an identifier when script is run as another user

I am new to scripting

I keep getting the error var2= is not an identifier when I run this script as another user. BUT when I run it as myself, the script completes without error. Any idea why? I assume it is because the new user has a different environment . How do I make the variables active for this new user? I don't have setenv and I've already exported them. As I said, the script works fine until i run it after logging in and running su - newuser to change to the newuser. I wish I could fix this so the newuser could also run the script.

echo "enter filername" 
read filername 
echo "enter days ago" 
read daysago 
command=`/px/finderquery -client=$filername -days=$daysago`; 
export var2=`echo $command`; 
if [[ `echo $var2 |grep show` ]]; 
then 
     echo "filer does not exist"; 
else 
     echo "you have the right name";
fi; 
export new2=`echo $var2 |gawk '{print $31}'`

Any ideas would be helpful to a newbie, thanks!

What shell are you using?

I wonder if it is not a shell issue... Since in your code there is no shell, it will use your default, I suppose yours is a bash ( looking at your syntax...) it may not be true for your other user... otherwise it has to be something with your environment...

duh... I should have told you I was using bash shell!

try puttinf as first line of your script:

#!/bin/bash

and see if it changes anything...( I suppose you made the script executable...) I cant do more, I dont use bash...

VBE: Dude, you are so right! The other user is running csh! Thanks for the help. I guess I will have to look into how csh treats variables. Maybe it uses setenv or something like that! Thanks for the help and if you have any further suggestions, let me know.

---------- Post updated at 01:41 PM ---------- Previous update was at 11:59 AM ----------

VBE you were right! using the #!/bin/bash fixed it! THANKS A MILLION!