Ssh and pgrep not working

I have setup SSH keys . Trying to grep to get PID of remote jvm's .

this is what am doing

ssh -q testuser1@myhost.com 'PID1=pgrep -fl testapp1|awk "{print $1}";PID2=pgrep -fl testapp2|awk "{print $1}" '
echo $PID1, $PID2

it throws error" sh: -fl: command not found"

---------- Post updated at 07:36 PM ---------- Previous update was at 07:12 PM ----------

please ignore my question , I was able to figure out

cat remotescript
#!/bin/sh
PID1=`pgrep -fl testapp1 | awk '{print $1}'`
PID2=`pgrep -fl testapp2 | awk '{print $1}'`
echo $PID1,$PID2
ssh -q testuser1@myhost.com /bin/sh < remotescript