Your specific error messages are showing up because:
assigning to a variable is not done with the $ character as in $msg="", instead you should be using msg=""; and
[ is actually a command, one that should be separated from other words by white space, so that the shell doesn't think you're trying to execute some mythical [i command.
However, you have a couple of other problems. The first is that the value of i needs to be obtained with $i, not just i. Using i on its own will give you an error along the lines of:
-bash: [: i: integer expression expected
because i itself is not a numeric value.
Secondly, neither i nor $i is going to be an index that you can compare with 1, so your $i -gt 1 expression will not work. The word $i will expand to the value of the argument, not its index.
However, if you really want to process all but the first element of your argument list, bash has some very C-like constructs which will make your life a lot easier:
for ((i = 2; i <= $#; i++)) ; do # From two to argc inclusive.
echo Processing ${!i}
done
Running that with the arguments hello my name is pax, will result in:
Processing my
Processing name
Processing is
Processing pax
For constructing a string containing those arguments, you could use something like:
msg="$2" # Second arg (or blank if none).
for ((i = 3; i <= $#; i++)) ; do # Append all other args.
msg="$msg ${!i}"
done
which will give you (for the same arguments as above):
[my name is pax]
Although, in that case, there's an even simpler approach which doesn't involve any (explicit) loops at all:
msg="${@:2}"
test: line 3: =: command not found) comes from an error in the assignment ofmsg: replace line 3 withmsg=""(no dollar, this is shell, not Perl or PHP).