If I execute the following shell command locally, I get the expected result:    adb -s 123456789 shell su -c 'mount -o remount,rw /system;rm -r /system/app/MyApp.apk;cp /sdcard/MyApp.apk /system/app/MyApp.apk;chmod 644 /system/app/MyApp.apk;'Basically, adb is the android debug bridge and I use it to open a shell on device 123456789. The outer set of   is used to encapsulate the commands that must be executed in the shell. The inner set of ' ' is used to encapsulate the set of commands that must be executed as a super user on she shell. All of this works properly, and I get the expected result.However if I try to execute this command through ssh:    ssh -i <path to rsa id file> root@<address> adb -s 123456789 shell su -c 'mount -o remount,rw /system;rm -r /system/app/MyApp.apk;cp /sdcard/MyApp.apk /system/app/MyApp.apk;chmod 644 /system/app/MyApp.apk;'The commands don't get parsed correctly, and I get the following errors:Usage: su [options] [--] [-] [LOGIN] [--] [args...]Options:   --daemon                      start the su daemon agent   -c, --command COMMAND         pass COMMAND to the invoked shell   -h, --help                    display this help message and exit   -, -l, --login                pretend the shell to be a login shell   -m, -p,   --preserve-environment        do not change environment variables   -s, --shell SHELL             use SHELL instead of the default /system/bin/sh   -u                            display the multiuser mode and exit   -v, --version                 display version number and exit   -V                            display version code and exit,                                 this is used almost exclusively by Superuser.apkmount: can't find /data in /etc/fstab  rm: cannot remove '/system/app/MyApp.apk': No such file or directory  cp: cannot stat '/sdcard/MyApp.apk': No such file or directory  chmod: cannot access '/system/app/MyApp.apk': No such file or directoryWhich leads me to believe that the commands do not get parsed correctly. I tried encapsulating the ssh'd command like this, but it didn't work (I tried with single and double quotes):    ssh -i <path to rsa id file> root@<address> adb -s 123456789 shell su -c 'mount -o remount,rw /system;rm -r /system/app/MyApp.apk;cp /sdcard/MyApp.apk /system/app/MyApp.apk;chmod 644 /system/app/MyApp.apk;'I'm not a big Linux user and I tried searching around but I came up with nothing. Is there a way to execute my command through ssh? EDIT:I seem to have pin-pointed the problem. If I execute this simple command everything works perfectly:        ssh root@ adb shell su -c 'ls -l'If I execute two commands with no parameters, I also get the expected output:        ssh root@ adb shell su -c 'ls;ls'However, if I execute the two commands and if both commands have an additional parameter, I get an error:        ssh root@ adb shell su -c 'ls -l;ls -l'The first command runs correctly (I get a list with the -l parameter), but instead of getting the list of files a second time I get the /system/bin/sh: ls -l: not found message. What is going on? This should be simpler to troubleshoot than my first post which had long, specific commands with multiple nested quotes.
Shell command works locally but does not get parsed correctly through ssh
shell script;ssh;quoting