[Edify question]-piping not working-how to selectively chmod certain files? - General Questions and Answers

I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?

Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!

Related

Batch file rename

Im trying to rename some files from .mp4 to .tmp and dont know how to go about this. I a little new to Linux commands, didnt start to learn till i got my G1. I know you can use the mv command to rename files but doesnt seem like you can do that in a batch. Wanna hide the porn on my phone from the little women and it shows up in the gallery
I don't know exactly, but try
mv *.mp4 *.tmp
I did try that and I get a error "failed on <fileName> - Invalid argument"
just open a DOs window..
cd to the directory you wan't to rename and type ren *.tmp *.mp4
eg:
cd C:\Myfiles
ren *.tmp *.mp4
Yep i know how to in DOS, but basically I want to create two scripts, one to rename them to .tmp and another one to rename them back to .mp4 and be able to run the scripts from the phone. I was thinking of maybe created a little app to do this, i do know abit about java script from a web development standpoint.
ok.. if you want to run it from the phone.. than it wont be a batch script woudl be an shell script bash script with is *nix format...
try this.. save it inside /system/bin as ren.sh chmod it to 777 or 755 and use it liek this
to rename mp4 to tmp use sh ren.sh mp4 | to rename mp4 to tmp use sh ren.sh tmp
Code:
if [ $1 = "tmp" ];
then
for f in *.tmp; do mv "$f" "`basename "$f" .tmp`.mp4"; done;
elif [ $1 = "mp4" ];
then
for f in *.mp4; do mv "$f" "`basename "$f" .mp4`.tmp"; done;
fi
when i try to run it i get "failed on '*.mp4' - No such file or directory"
sh ren.sh mp4 was the command I sent.
are you running it insicde the directory where teh tmp or mp4 files are located?
Sweet that worked. One thing though is that it i get a message after its done saying ": not found". Also is there a way I can use that sh without having to put the full path to the sh. right now it only works like this
Code:
cd /sdcard/downloads
sh /system/bin/ren.sh mp4
PS thank you for the help.
MonkySlap said:
Sweet that worked. One thing though is that it i get a message after its done saying ": not found". Also is there a way I can use that sh without having to put the full path to the sh. right now it only works like this
Code:
cd /sdcard/downloads
sh /system/bin/ren.sh mp4
PS thank you for the help.
Click to expand...
Click to collapse
should respond with chmod 755 /system/bin/ren.sh i think .. then it'll run from anywhere
LucidREM said:
should respond with chmod 755 /system/bin/ren.sh i think .. then it'll run from anywhere
Click to expand...
Click to collapse
i would just rename it "ren" and you should be able to "ren tmp" etc
LucidREM said:
i would just rename it "ren" and you should be able to "ren tmp" etc
Click to expand...
Click to collapse
That worked. Thank you. now i get to watch cake and eat it too lol
as i said before, you need to put the file inside your bin directory, and chmod to 755 or 777 which ever works not sure as LucidREM said move it to /system/bin and chmod it
than u can be abel to use ren.sh mp4 ect..

[Q] set_perm_recursive to set_perm question

I've been searching for a guide to help me understand the syntax set_perm and set_perm_recursive, but can not find anything from googling these terms and explanations of how to use them and what values to use for a particular permission...
What I'm trying to do is create a flashable zip with apks ( some stored in the /system/app & some in the /data/app ), and with the updater-script file I've cut it down to the necessity syntaxs but having problems with the above syntax... I see that I can set permissions to all files within the /system/app folder ( using set_perm_recursive(0, 0, 0755, 0644, "/system/app"); syntax ), however I don't want/need to set all the file permissions in /system/app folder that have already been set from the initial rom flash, so using set_perm(x, x, x, "/path"); syntax instead I want to set each file I flash into the /system/app folder ( from the flashable zip ) individually to the exact same permissions as set_perm_recursive I pasted above... So, can I just remove the _recursive & 0644, parts of the syntax so that it looks like this set_perm(0, 0, 0755, "/system/app/xxx.apk"); for each individual file permission?
Much appreciate the response and hope you all understand what I'm trying to achieve, cuz I was kinda confused a little when writing this!
Cheers all
trueno2k said:
I've been searching for a guide to help me understand the syntax set_perm and set_perm_recursive, but can not find anything from googling these terms and explanations of how to use them and what values to use for a particular permission...
What I'm trying to do is create a flashable zip with apks ( some stored in the /system/app & some in the /data/app ), and with the updater-script file I've cut it down to the necessity syntaxs but having problems with the above syntax... I see that I can set permissions to all files within the /system/app folder ( using set_perm_recursive(0, 0, 0755, 0644, "/system/app"); syntax ), however I don't want/need to set all the file permissions in /system/app folder that have already been set from the initial rom flash, so using set_perm(x, x, x, "/path"); syntax instead I want to set each file I flash into the /system/app folder ( from the flashable zip ) individually to the exact same permissions as set_perm_recursive I pasted above... So, can I just remove the _recursive & 0644, parts of the syntax so that it looks like this set_perm(0, 0, 0755, "/system/app/xxx.apk"); for each individual file permission?
Much appreciate the response and hope you all understand what I'm trying to achieve, cuz I was kinda confused a little when writing this!
Cheers all
Click to expand...
Click to collapse
Don't know if you're still requiring this, but you can take a look at this:
Function Name: set_perm
Function Syntax: set_perm(uid, gid, mode, file1, file2, ..., fileN)
Parameter Details:
uid = user id
gid = group id
mode = permission mode
fileX = file to set permission on
These 4 attributes are necessary, hope it helps!
more insight
Function Name: set_perm_recursive
Function Syntax: set_perm_recursive(uid, gid, dirmode, filemode, dir1, dir2, ...dirN)
Parameter Details:
uid = user id
gid = group id
dirmode = permission to set to directories contained within the specified directory
filemode = permission to set to files contained within the specified directory
dirX = directory to set permission on
Action: Set permissions of a directory or set of directories and all files and folders within them. At least one directory must be specified (The first 5 parameters are required)
hope it helps and know that sure as hell it did help me, cheers

[Edify question]-piping not working-how to selectively chmod certain files?

I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!

[Edify question]-piping not working-how to selectively chmod certain files?

I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!

permission backup system - TWRP

Hello,
I have a script in TWRP
I trying to take backup of the android system all in: "/system"
into a sdcard "/external_sd/backupOSUmidigiPower"
Code:
ui_print("Start");
run_program("/sbin/busybox", "mount", "/dev/block/mmcblk0p31", "/system");
run_program("/sbin/busybox", "mkdir", "-p", "/external_sd/backupOSUmidigiPower");
run_program("/sbin/busybox", "cp", "-rp", "/system", "/external_sd/backupOSUmidigiPower/");
ui_print("Finish");
That Works very fine and take backup into sd card
But then i trying to take restore backup back to "/system"
but my question is:
1. "Why is my permission gone, see photo"
2. How can i copy all files/folder with permissions
linux cp commands:
Code:
cp
copy with recursion (-r) and (-p) preserve mode,ownership,timestamps
sudo cp -rp <sourceDir> <destDir>
And still got chmod 777 permission on all files/folders
I got bootloop before i think file permission is chmod 777
Can you help me out
Thanks for your time
I experienced that cp command always changes ownership of copied files / directories to root:root regardless of their initial ownership.
jwoegerbauer said:
I experienced that cp command always changes ownership of copied files / directories to root:root regardless of their initial ownership.
Click to expand...
Click to collapse
How can i move files and keep permission?
Moving and Copying are different things.
Don't confuse file's / directory's permissions and file's / directory's ownership: these are different things.

Categories

Resources