Menu

Error on Mototorola Moto G2 with MM

Giangi
2017-07-01
2017-07-27
1 2 > >> (Page 1 of 2)
  • Giangi

    Giangi - 2017-07-01

    I know that this project has been silent since long ago, but this script is still the only option to keep timestamps!!!

    So far I managed to run it on the pc (using cygwin) because it's not running on my Moto G2 for reading timestams.
    Today I decided it was time to try opening a discussion! :)

    So, right now the MotoG2 is rooted with Magisk v12, without external busybox but enabled the (basic) internal one.
    In the past I MAY (I actually do not remember) have tried using SuperSU and BusyBox from Stericson.

    To me it looks like the "stat" cmd I have is not supporting the format used into the script

    Here yuo are an output from adb shell:

    1|shell@titan_umtsds:/sdcard $
    1|shell@titan_umtsds:/sdcard $ su
    root@titan_umtsds:/storage/emulated/0 # sh stamps.sh read .
    Working on dir: ./
    stat: '{}': No such file or directory
    stat: '{}': No such file or directory
    

    Just in case, this is the help output of the "stat" available on my phone!

    usage: stat [-f] [-c FORMAT] FILE...
    
    Display status of files or filesystems.
    
    -f display filesystem status instead of file status
    -c Output specified FORMAT string instead of default
    
    The valid format escape sequences for files:
    %a  Access bits (octal) |%A  Access bits (flags)|%b  Blocks allocated
    %B  Bytes per block     |%d  Device ID (dec)    |%D  Device ID (hex)
    %f  All mode bits (hex) |%F  File type          |%g  Group ID
    %G  Group name          |%h  Hard links         |%i  Inode
    %n  Filename            |%N  Long filename      |%o  I/O block size
    %s  Size (bytes)        |%u  User ID            |%U  User name
    %x  Access time         |%X  Access unix time   |%y  File write time
    %Y  File write unix time|%z  Dir change time    |%Z  Dir change unix time
    
    The valid format escape sequences for filesystems:
    %a  Available blocks    |%b  Total blocks       |%c  Total inodes
    %d  Free inodes         |%f  Free blocks        |%i  File system ID
    %l  Max filename length |%n  File name          |%s  Fragment size
    %S  Best transfer size  |%t  File system type
    
     
  • dragomerlin

    dragomerlin - 2017-07-08

    What happens if you do
    sh stamps.sh read /sdcard/

     
  • Giangi

    Giangi - 2017-07-14

    Sorry for the late reply... SF didn't notify me...

    Nothing changed:

    adb shell
    shell@titan_umtsds:/ $ su
    root@titan_umtsds:/ # cd sdcard
    root@titan_umtsds:/sdcard # sh stamps.sh read /sdcard/
    Working on dir: /sdcard//
    stat: '{}': No such file or directory
    

    Isn't strange that the "working on" reports the path with a double slash?
    Without the trailing slash I got this error

    root@titan_umtsds:/sdcard # sh stamps.sh read /sdcard
    Missing directory: /sdcard
    

    same error without the starting slash

    1|root@titan_umtsds:/sdcard # sh stamps.sh read sdcard/
    Missing directory: sdcard/
    

    BTW: I know really a little of Linux...

     
  • dragomerlin

    dragomerlin - 2017-07-14

    The double dash does not affect. The script adds a dash always in case you put only the name so it always has a dash at least at the end.

    Try the newer version stamps-v2.5-busybox_stat.sh wich uses the stat from busybox instead of the default from android.

     
  • Giangi

    Giangi - 2017-07-15

    Hi,

    nothing changed... :-(

    I have used this https://play.google.com/store/apps/details?id=stericson.busybox

    Could you change the script so it will "echo" the cmd being executed? It could help understanding what is wrong... I know how to do using the MS commands but I do known nothing abouth bash... :-(

     
  • Giangi

    Giangi - 2017-07-15

    BTW, this is the new stat currently installed help

    root@titan_umtsds:/sdcard # busybox stat
    BusyBox v1.26.2-Stericson (2017-01-14 16:15:58 PST) multi-call binary.
    
    Usage: stat [OPTIONS] FILE...
    
    Display file (default) or filesystem status
    
            -c FMT  Use the specified format
            -f      Display filesystem status
            -L      Follow links
            -t      Terse display
    
    FMT sequences for files:
     %a     Access rights in octal
     %A     Access rights in human readable form
     %b     Number of blocks allocated (see %B)
     %B     Size in bytes of each block reported by %b
     %d     Device number in decimal
     %D     Device number in hex
     %f     Raw mode in hex
     %F     File type
     %g     Group ID
     %G     Group name
     %h     Number of hard links
     %i     Inode number
     %n     File name
     %N     File name, with -> TARGET if symlink
     %o     I/O block size
     %s     Total size in bytes
     %t     Major device type in hex
     %T     Minor device type in hex
     %u     User ID
     %U     User name
     %x     Time of last access
     %X     Time of last access as seconds since Epoch
     %y     Time of last modification
     %Y     Time of last modification as seconds since Epoch
     %z     Time of last change
     %Z     Time of last change as seconds since Epoch
    
    FMT sequences for file systems:
     %a     Free blocks available to non-superuser
     %b     Total data blocks
     %c     Total file nodes
     %d     Free file nodes
     %f     Free blocks
     %i     File System ID in hex
     %l     Maximum length of filenames
     %n     File name
     %s     Block size (for faster transfer)
     %S     Fundamental block size (for block counts)
     %t     Type in hex
     %T     Type in human readable form
    1|root@titan_umtsds:/sdcard #
    
     
  • dragomerlin

    dragomerlin - 2017-07-15

    Try the newer version which uses busybox find instead of the find included in the smartphone.

    https://sourceforge.net/projects/androidtimestampkeeper/files/stamps-v2.6-busybox_stat_find.sh/download

    Try going to the sdcard and do find:
    cd /sdcard/
    find .

    And look if it lists all the contents of the sdcard.
    What my script does it uses find to list all the files (excluded folders) and on each result of find executes the command stat to get the attributes and then uses sed to sort them and puts everything inside a text file.

    Try:
    cd /sdcard/
    find . > mylist.txt
    And see if the txt file contains stuff.
    Also check the options of your find (use "find" and "busybox find" alternatively on examples) and see if the option -exec is allowed.

     

    Last edit: dragomerlin 2017-07-15
  • Giangi

    Giangi - 2017-07-17

    Yes, it finds something...

    shell@titan_umtsds:/ $ su
    root@titan_umtsds:/ # cd /sdcard/
    root@titan_umtsds:/sdcard # find .
    .
    ./Android
    ./Android/media
    ./Android/media/com.android.providers.media
    ./Android/media/com.google.android.talk
    ./Android/media/com.google.android.talk/Notifications
    ./Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    

    here you are the system's find help...

    1|root@titan_umtsds:/sdcard # find --help
    usage: find [-HL] [DIR...] [<options>]
    
    Search directories for matching files.
    Default: search "." match all -print all matches.
    
    -H  Follow command line symlinks         -L  Follow all symlinks
    
    Match filters:
    -name  PATTERN filename with wildcards   -iname      case insensitive -name
    -path  PATTERN path name with wildcards  -ipath      case insensitive -path
    -user  UNAME   belongs to user UNAME     -nouser     user not in /etc/passwd
    -group GROUP   belongs to group GROUP    -nogroup    group not in /etc/group
    -perm  [-]MODE permissons (-=at least)   -prune      ignore contents of dir
    -size  N[c]    512 byte blocks (c=bytes) -xdev       stay in this filesystem
    -links N       hardlink count            -atime N    accessed N days ago
    -ctime N       created N days ago        -mtime N    modified N days ago
    -newer FILE    newer mtime than FILE     -mindepth # at least # dirs down
    -depth         ignore contents of dir    -maxdepth # at most # dirs down
    -type [bcdflps] (block, char, dir, file, symlink, pipe, socket)
    
    Numbers N may be prefixed by a - (less than) or + (greater than):
    
    Combine matches with:
    !, -a, -o, ( )    not, and, or, group expressions
    
    Actions:
    -print   Print match with newline  -print0    Print match with null
    -exec    Run command with path     -execdir   Run command in file's dir
    -ok      Ask before exec           -okdir     Ask before execdir
    
    Commands substitute "{}" with matched file. End with ";" to run each file,
    or "+" (next argument after "{}") to collect and run with multiple files.
    

    ...and this is busybox's find help

    root@titan_umtsds:/sdcard # busybox find --help
    BusyBox v1.26.2-Stericson (2017-01-14 16:15:58 PST) multi-call binary.
    
    Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]
    
    Search for files and perform actions on them.
    First failed action stops processing of current file.
    Defaults: PATH is current directory, action is '-print'
    
            -L,-follow      Follow symlinks
            -H              ...on command line only
            -xdev           Don't descend directories on other filesystems
            -maxdepth N     Descend at most N levels. -maxdepth 0 applies
                            actions to command line arguments only
            -mindepth N     Don't act on first N levels
            -depth          Act on directory *after* traversing it
    
    Actions:
            ( ACTIONS )     Group actions for -o / -a
            ! ACT           Invert ACT's success/failure
            ACT1 [-a] ACT2  If ACT1 fails, stop, else do ACT2
            ACT1 -o ACT2    If ACT1 succeeds, stop, else do ACT2
                            Note: -a has higher priority than -o
            -name PATTERN   Match file name (w/o directory name) to PATTERN
            -iname PATTERN  Case insensitive -name
            -path PATTERN   Match path to PATTERN
            -ipath PATTERN  Case insensitive -path
            -regex PATTERN  Match path to regex PATTERN
            -type X         File type is X (one of: f,d,l,b,c,...)
            -perm MASK      At least one mask bit (+MASK), all bits (-MASK),
                            or exactly MASK bits are set in file's mode
            -mtime DAYS     mtime is greater than (+N), less than (-N),
                            or exactly N days in the past
            -mmin MINS      mtime is greater than (+N), less than (-N),
                            or exactly N minutes in the past
            -newer FILE     mtime is more recent than FILE's
            -inum N         File has inode number N
            -user NAME/ID   File is owned by given user
            -group NAME/ID  File is owned by given group
            -size N[bck]    File size is N (c:bytes,k:kbytes,b:512 bytes(def.))
                            +/-N: file size is bigger/smaller than N
            -links N        Number of links is greater than (+N), less than (-N),
                            or exactly N
            -prune          If current file is directory, don't descend into it
    If none of the following actions is specified, -print is assumed
            -print          Print file name
            -print0         Print file name, NUL terminated
            -exec CMD ARG ; Run CMD with all instances of {} replaced by
                            file name. Fails if CMD exits with nonzero
            -exec CMD ARG + Run CMD with {} replaced by list of file names
            -delete         Delete current file/directory. Turns on -depth option
    
     
  • dragomerlin

    dragomerlin - 2017-07-25

    cd /sdcard/

    stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    busybox stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    busybox stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    busybox stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"

    busybox find Android/media/com.google.android.talk/Notifications/hangouts_message.ogg -type f -exec sh -c 'busybox stat -c %n "{}" ' \; -exec busybox stat -c %Y "{}" \; -exec sh -c 'busybox stat -c %y "{}" | sed -e 's/-//g' | sed -e 's/://g' | sed -e "s/ //g" | cut -d '.' -f1 | sed "s/./.&/13" ' \;

     
  • Giangi

    Giangi - 2017-07-25

    ok, here you are the first three stat...

    130|root@titan_umtsds:/sdcard # stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    2017-05-25 15:37:43.000000000
    root@titan_umtsds:/sdcard # stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    root@titan_umtsds:/sdcard # stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    1495719463
    

    ...the busybox's stat...

    root@titan_umtsds:/sdcard # busybox stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    2017-05-25 13:37:43.000000000
    root@titan_umtsds:/sdcard # busybox stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    root@titan_umtsds:/sdcard # busybox stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
    1495719463
    

    ...and the last test; it left the input open, I had to press ctrl+c to go back to the prompt...

    root@titan_umtsds:/sdcard # busybox find Android/media/com.google.android.talk/Notifications/hangouts_message.ogg -type edia/com.google.android.talk/Notifications/hangouts_message.ogg -type f -exec sh -c 'busybox stat -c %n                 s_message.ogg -type f -exec sh -c 'busybox stat -c %n "{}" ' \; -exec busybox stat -c %Y "{}" \; -exec s                 %n "{}" ' \; -exec busybox stat -c %Y "{}" \; -exec sh -c 'busybox stat -c %y "{}" | sed -e 's/-//g' |                 ec sh -c 'busybox stat -c %y "{}" | sed -e 's/-//g' | sed -e 's/://g' | sed -e "s/ //g" | cut -d '.' -f1                 | sed "s/./.&/13" ' \;           <
    Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    1495719463
    
    ^C
    

    Ciao!

     
  • Giangi

    Giangi - 2017-07-25

    BTW, v2.6 has worked but only for the first file in "read" mode!! :-)

    I had to ctrl+c to stop and the file had only one file inside...

     

    Last edit: Giangi 2017-07-25
  • dragomerlin

    dragomerlin - 2017-07-25

    This is what I get with Cygwin:

    $ find .profile -type f -exec sh -c 'stat -c %n "{}" ' \; -exec stat -c %Y "{}" \; -exec sh -c 'stat -c %y "{}" | sed -e 's/-//g' | sed -e 's/://g' | sed -e "s/ //g" | cut -d '.' -f1 | sed "s/./.&/13" ' \;
    .profile
    1500983971
    201707251359.31
    

    Looks like your commands are working with and without busybox. Use the code icon to post better. What is the problem now, does not work?

     
  • Giangi

    Giangi - 2017-07-26

    As I wrote, v26 it works, but only for the first file and then it hung. The generated file, after about 10 minutes, contains only one entry...

    ./Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    1495719463
    
     
  • Giangi

    Giangi - 2017-07-26

    Hi hope you can understand the following... I have added a "set -x" and this is the output, but only for the first iteration... probably I should put another "set -x" inside the last (very complex) statement!

    with v24 script

    root@titan_umtsds:/sdcard # sh stamps-v24.sh  read .
    + >/dev/null
    + 2>&1
    + command -v find
    + >/dev/null
    + 2>&1
    + command -v sed
    + >/dev/null
    + 2>&1
    + command -v ps
    + cname=0
    + cdate=0
    + '[' read '!=' read ']'
    + sed -e 's,/\+$,,'
    + echo .
    + WDIR=./
    + echo 'Working on dir: ./'
    Working on dir: ./
    + '[' read '=' read ']'
    + rm timestamps.txt
    + >>timestamps.txt
    + cd ./
    + find . -type f -exec sh -c 'stat -c %n "{}" ' ';' -exec stat -c %Y {} ';' -exec sh -c 'stat -c %y "{}" | sed -e s/-//g | sed -e s/://g | sed -e "s/ //g" | cut -d . -f1 | sed "s/./.&/13" ' ';'
    stat: '{}': No such file or directory
    stat: '{}': No such file or directory
    
     
  • Giangi

    Giangi - 2017-07-26

    ...with v25...

    + >/dev/null
    + 2>&1
    + command -v find
    + >/dev/null
    + 2>&1
    + command -v sed
    + >/dev/null
    + 2>&1
    + command -v ps
    + cname=0
    + cdate=0
    + '[' read '!=' read ']'
    + sed -e 's,/\+$,,'
    + echo .
    + WDIR=./
    + echo 'Working on dir: ./'
    Working on dir: ./
    + '[' read '=' read ']'
    + rm timestamps.txt
    + >>timestamps.txt
    + cd ./
    + find . -type f -exec sh -c 'busybox stat -c %n "{}" ' ';' -exec busybox stat -c %Y {} ';' -exec sh -c 'busybox stat -c %y "{}" | sed -e s/-//g | sed -e s/://g | sed -e "s/ //g" | cut -d . -f1 | sed "s/./.&/13" ' ';'
    stat: can't stat '{}': No such file or directory
    stat: can't stat '{}': No such file or directory
    
     
  • Giangi

    Giangi - 2017-07-26

    ...with v26...

    + >/dev/null
    + 2>&1
    + command -v find
    + >/dev/null
    + 2>&1
    + command -v sed
    + >/dev/null
    + 2>&1
    + command -v ps
    + cname=0
    + cdate=0
    + '[' read '!=' read ']'
    + sed -e 's,/\+$,,'
    + echo .
    + WDIR=./
    + echo 'Working on dir: ./'
    Working on dir: ./
    + '[' read '=' read ']'
    + rm timestamps.txt
    + >>timestamps.txt
    + cd ./
    + busybox find . -type f -exec sh -c 'busybox stat -c %n "{}" ' ';' -exec busybox stat -c %Y {} ';' -exec sh -c 'busybox stat -c %y "{}" | sed -e s/-//g | sed -e s/://g | sed -e "s/ //g" | cut -d . -f1 | sed "s/./.&/13" ' ';'
    ^C
    
     
  • dragomerlin

    dragomerlin - 2017-07-26

    Ok try only read with the script "stamps-test-1.sh". Don't use write is not compatible.

     
  • Giangi

    Giangi - 2017-07-26

    oh YES! It worked! :-) Here you are the first lines...

    ./Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
    1495719463
    2017-05-25 13:37:43.000000000
    ./Android/media/com.google.android.talk/Ringtones/hangouts_incoming_call.ogg
    1495719463
    2017-05-25 13:37:43.000000000
    ./Android/data/.nomedia
    1452108959
    2016-01-06 19:35:59.000000000
    ./Android/data/com.google.android.apps.maps/testdata/voice/it_IT.c279fc03/voice_instructions.zip
    1480987019
    2016-12-06 01:16:59.000000000
    ./Android/data/com.google.android.apps.maps/cache/cache_r.0
    1500657828
    2017-07-21 17:23:48.000000000
    

    This is the ls output, I bet the time is GMT (my computer is on CEST)

    1|shell@titan_umtsds:/sdcard/Android/media/com.google.android.talk $ ls -l -R
    
    .:
    drwxrwx--x root     sdcard_rw          2016-08-23 00:48 Notifications
    drwxrwx--x root     sdcard_rw          2016-08-23 00:48 Ringtones
    
    ./Notifications:
    -rw-rw---- root     sdcard_rw    30056 2017-05-25 15:37 hangouts_message.ogg
    
    ./Ringtones:
    -rw-rw---- root     sdcard_rw    76425 2017-05-25 15:37 hangouts_incoming_call.ogg
    
     
  • dragomerlin

    dragomerlin - 2017-07-27

    Ok try stamps-v2.7.sh should work to read and write. To check a single file just edit timestamps.txt and leave the 3 lines for a file you want to test with, for example put a file in sdcard.

     
  • Giangi

    Giangi - 2017-07-27

    The read has worked but I got this error at the end

    shell@titan_umtsds:/ $ su
    root@titan_umtsds:/ # cd sdcard/
    root@titan_umtsds:/sdcard # sh st
    stamps.sh  stamps.txt
    root@titan_umtsds:/sdcard # sh stamps.sh read .
    Working on dir: ./
    sed: bad pattern '3~3 s/-//g'@3 (3)
    sed: bad pattern '3~3 s/://g'@3 (3)
    sed: bad pattern '3~3 s/ //g'@3 (3)
    sed: bad pattern '3~3 s/\..*//'@3 (3)
    sed: bad pattern '3~3 s/./.&/13'@3 (3)
    root@titan_umtsds:/sdcard #
    

    Now I will try the write.

    BTW, I have compared v2.4 with v2.7 and found you have delete every references to "busybox", not only in comments but also in code for "write". Is that correct or a side-effect from testing? :)

     
  • Giangi

    Giangi - 2017-07-27

    The write operation has failed with v2.7 :(

    root@titan_umtsds:/sdcard # sh stamps.sh write backups/
    Working on dir: backups//
    touch: invalid date '2017-07-12 14:17:26.000000000'
    root@titan_umtsds:/sdcard #
    

    Same error with v2.4

     

    Last edit: Giangi 2017-07-27
  • Giangi

    Giangi - 2017-07-27

    Here you are the system's touch help

    usage: touch [-amch] [-d DATE] [-t TIME] [-r FILE] FILE...
    
    Update the access and modification times of each FILE to the current time.
    
    -a      change access time
    -m      change modification time
    -c      don't create file
    -h      change symlink
    -d      set time to DATE (in YYYY-MM-DDThh:mm:SS[.frac][tz] format)
    -t      set time to TIME (in [[CC]YY]MMDDhhmm[.ss][frac] format)
    -r      set time same as reference FILE
    

    ...and this the busybox's one

    BusyBox v1.26.2-Stericson (2017-01-14 16:15:58 PST) multi-call binary.
    
    Usage: touch [-c] [-d DATE] [-t DATE] [-r FILE] FILE...
    
    Update the last-modified date on the given FILE[s]
    
            -c      Don't create files
            -h      Don't follow links
            -d DT   Date/time to use
            -t DT   Date/time to use
            -r FILE Use FILE's date/time
    

    Could it be that the parameter to use is -d since mine stat is formatting both date and time?

    ./backup_12_lug_2017_16-17-25.seb
    1499869046
    2017-07-12 14:17:26.000000000
    
     

    Last edit: Giangi 2017-07-27
  • Giangi

    Giangi - 2017-07-27

    I have modified timestamps.txt removing the separators and now the v2.7 "write" has restored the date I have changed! :-)

    ./backup_12_lug_2017_16-17-25.seb
    1499869046
    201707121417.26
    
     
  • dragomerlin

    dragomerlin - 2017-07-27

    Try these commands and see if work:

    echo -e "house\nhouse\nhouse\nhouse"
    
    Must display:
    house
    house
    house
    house
    

    Another:

    echo -e "house\nhouse\nhouse\nhouse" | sed '3~3 s/house/cat/g'
    
    Must display:
    house
    house
    cat
    house
    

    This the same result as before:

    echo -e "house\nhouse\nhouse\nhouse" | busybox sed '3~3 s/house/cat/g'
    
     

    Last edit: dragomerlin 2017-07-27
  • Giangi

    Giangi - 2017-07-28

    Here you are the first...

    root@titan_umtsds:/ # echo -e "house\nhouse\nhouse\nhouse"
    house
    house
    house
    house
    

    ...the second (BTW, inside the "adb shell" launched from Win10 command I cannot type the tilde ~! I had to launch adb shell from Cygwin but I do not like it because I cannot have the same cursor's movements and copy&paste as from the Win10 command...) gives a sed's error...

    root@titan_umtsds:/ # echo -e "house\nhouse\nhouse\nhouse" | sed '3~3 s/house/cat/g'
    echo -e "house\nhouse\nhouse\nhouse" | sed '3~3 s/house/cat/g'
    sed: bad pattern '3~3 s/house/cat/g'@3 (3)
    

    ...the third too gives a sed's error...

    1|root@titan_umtsds:/ # echo -e "house\nhouse\nhouse\nhouse" | busybox sed '3~3 s/house/cat/g'
    echo -e "house\nhouse\nhouse\nhouse" | busybox sed '3~3 s/house/cat/g'
    sed: unsupported command ~
    
     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.