0

I wrote this script for copying XML files I received to a spot on my sdcard. However when I run it in terminal i get the following. Can someone explain if i did something wrong or whats going on?

  • cd /data/com.idv.android/cache/receivedxml/
  • /data/xml.sh[4]: cd: /data/com.idv.android/: No such file or directory
  • /data/xml.sh[7]: syntax error: 'cat' unexpected

Additional info: Samsung Galaxy S2 Skyrocket / Rooted /

#!/system/bin/sh
set -x verbose

cd /data/data/com.idv.android/cache/receivedxml/
if ls *.xml &> /dev/null; then
  for file in *.xml
  do
    cat "$file" > "/storage/sdcard0/XMLList/${file}"
  done
fi
exit

3 Answers 3

1

cp and cat is not support by original android system. try install a busybox.

and, cd /data/*/ need root privilege.

13
  • I do have busybox installed. :/
    – IDV
    Sep 23, 2013 at 1:01
  • try 'busybox cp' intead of 'cp', 'busybox cat' instead of 'cat'.
    – afpro
    Sep 23, 2013 at 1:02
  • If I change the header to #!/System/xbin and run it i get /data/xml.sh: permission denied
    – IDV
    Sep 23, 2013 at 1:04
  • su -c 'sh xml.sh'?
    – afpro
    Sep 23, 2013 at 1:07
  • Get back permission denied on that also.
    – IDV
    Sep 23, 2013 at 1:10
0

Your shell may not be support things method: &> /dev/null. I think you can only do that in bash.

Try converting your line to:

if ls *.xml > /dev/null 2>&1; then

Also, just in case but try not to add leading spaces to your header:

#!/system/bin/sh
5
  • I put in both of the suggestions eg 2>*1; and using cp instead of cat and i still get the same results except syntax error: 'cp' unexpected.
    – IDV
    Sep 23, 2013 at 0:50
  • @IDV The script looks really fine. Try to check if you're saving it as DOS format instead. Run dos2unix script.sh.
    – konsolebox
    Sep 23, 2013 at 1:20
  • after I did this and ran it everything seemed fine, as in no messages came up, however it did not copy any files. I'm using cat btw.
    – IDV
    Sep 23, 2013 at 1:29
  • @IDV Did you check /storage/sdcard0/XMLList/? Also, make sure that *.xml do exist. Were there no messages shown even debug messages? Did you see your code going for the for loop?
    – konsolebox
    Sep 23, 2013 at 1:39
  • @konesolebox I checked /storage/sdcard0/XMLList and nothing was there. :/ There are 10+ .xml files. No messages were shown. I type in su /data/xml.sh and it just acts like you are ready to input a new command.
    – IDV
    Sep 23, 2013 at 1:45
-2

hash_config { algorithm: SCRYPT, base64_signer_key: 5BUuLHgCoYKEaPlKtGEqvmjhvha/JTIZH7wsb5IH2jgJRGPyce5YWeaXM/d3AGFdSjl6ubDZmD9XDIudpQRBkA==, base64_salt_separator: Bw==, rounds: 8, mem_cost: 14, }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .