Hey all together,
after a lot of searching and using Google for days with no really good results i created now my own reg-ex functions to parse some Android shell outputs. So i only want to share my functions coz i dun found something like that.
If u create a Android File-Explorer or something else like this u'll have to get the ls and df output in some situations, if u use C# like me this will be great for u. ;)
here are my functions:
(command) ls -l
(command) busybox ls -aFl
u can use it like
(command) df
(command) busybox df -Pakh
u can use it like
Hope this helps someone ;)
Regards,
k1ll3r8e
after a lot of searching and using Google for days with no really good results i created now my own reg-ex functions to parse some Android shell outputs. So i only want to share my functions coz i dun found something like that.
If u create a Android File-Explorer or something else like this u'll have to get the ls and df output in some situations, if u use C# like me this will be great for u. ;)
here are my functions:
(command) ls -l
(command) busybox ls -aFl
Code:
^(?<TYPE>(-|b|c|d|l|s|p){1})(?<PERM>(-|r|w|x|s|t){9})\s{1,}(?<INCLUDES>([0-9]){1,}\s{1,})?(?<OWNER>(.*?))\s{1,}(?<GROUP>(.*?))\s{1,}(?<ID>([0-9]){1,},\s{1,})?(?<SIZE>([0-9]){1,}\s{1,})?(?<DATE>(.*?))\s{1,}(?<TIME>([0-9]{2}.[0-9]{2}|[0-9]{4}))\s{1}(?<NAME>(.*?))(\s{1}->\s{1}(?<SYMLINK>(.*?)))?(?<SUBTYPE>(\*|/){1})?$
Code:
GroupCollection groups = Regex.Match("the ls -l or busybox -aFl output line by line", @"^(?<TYPE>(-|b|c|d|l|s|p){1})(?<PERM>(-|r|w|x|s|t){9})\s{1,}(?<INCLUDES>([0-9]){1,}\s{1,})?(?<OWNER>(.*?))\s{1,}(?<GROUP>(.*?))\s{1,}(?<ID>([0-9]){1,},\s{1,})?(?<SIZE>([0-9]){1,}\s{1,})?(?<DATE>(.*?))\s{1,}(?<TIME>([0-9]{2}.[0-9]{2}|[0-9]{4}))\s{1}(?<NAME>(.*?))(\s{1}->\s{1}(?<SYMLINK>(.*?)))?(?<SUBTYPE>(\*|/){1})?$").Groups;
string Type = groups["TYPE"].Value;
string SubType = groups["SUBTYPE"].Value;
string Perms = groups["PERM"].Value;
string Owner = groups["OWNER"].Value;
string Group = groups["GROUP"].Value;
string Id = groups["ID"].Value;
string Size = groups["SIZE"].Value;
string Date = String.Join(" ", groups["DATE"].Value, groups["TIME"].Value);
string Name = groups["NAME"].Value;
string[] extTmp = Name.Split('.');
string FileExtension = extTmp[extTmp.Length - 1];
string SymPath = groups["SYMLINK"].Value;
(command) df
(command) busybox df -Pakh
Code:
^(df:\s{1,})?(?<NAME>(.*?))(:\s{1,}(.*?))?(\s{1,}(?<SIZE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<USED>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<FREE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<BLOCKSIZE>([0-9]){1,}))?(\s{1,}(?<USE>([0-9]{1,})%))?(\s{1,}(?<PATH>(.*?)))?$
Code:
GroupCollection groups = Regex.Match("the df or df -Pakh output line by line", @"^(df:\s{1,})?(?<NAME>(.*?))(:\s{1,}(.*?))?(\s{1,}(?<SIZE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<USED>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<FREE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<BLOCKSIZE>([0-9]){1,}))?(\s{1,}(?<USE>([0-9]{1,})%))?(\s{1,}(?<PATH>(.*?)))?$").Groups;
string Name = groups["NAME"].Value;
string Size = groups["SIZE"].Value;
string Used = groups["USED"].Value;
string Free = groups["FREE"].Value;
string BlockSize = groups["BLOCKSIZE"].Value;
string Use = groups["USE"].Value;
string Path = groups["PATH"].Value;
Hope this helps someone ;)
Regards,
k1ll3r8e