I am running this command in android


pkgName=#some package name
su -c "cmd A && cmd B && am force-stop $pkgName" > /storage/emulated/0/log.txt 2>&1

the commands work fine but there is no output in the log.txt

2. when I run

pkgName=#some package name
su -c "{ cmd A && cmd B && am force-stop $pkgName; } > /storage/emulated/0/log.txt 2>&1"

Command A and b works fine, but the am force-stop fails for some reason.

3. When I run everything in sinlge quote

pkgName=#some pkg Name
pkgName="$pkgName" su -c 'cmd A && cmd B && am force-stop $pkgName' > /storage/emulated/0/log.txt 2>&1

everything works fine, but I have to specify multiple variables that were previously assigned to run this.

So, I want a fix to the upper, i.e., the first method.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.