[Help] wget/curl Script worked prior to MM? now no longer works - Android Q&A, Help & Troubleshooting

I had a script that I ran via tasker when I was on 5.1.1 to download the pic of the day from Nasa
https://apod.nasa.gov/apod/astropix.html
Since upgrading to MM the script no longer works. It does work just fine via command line on linux machines(most likely d/t the increased support and ease of wget/curl) so I know the formatting is correct.
here's what I have
Code:
#!/bin/sh
wget -q -c -O ~/Downloads/potd/$(date +%m-%d-%Y.jpg) https://apod.nasa.gov/$(curl -silent https://apod.nasa.gov/apod/astropix.html > astropix.html && grep "IMG SRC" astropix.html | cut -c 10- | tr -d "\"") && rm astropix.html
On android I get as far as
Code:
sslv3 alert handshake failure
Any help would be greatly appreciated. I've tried setting different ssl/tls versions via curl and still nothing.

Related

[Q] busybox and touch command

Who can help me with the syntax of the command touch?
Using the touch command as follows:
touch -d "01/01/2012 00:00:00" \ data \ data \ com.android.providers.telephony \ databases \ mmssms.db
the system outputs the following message:
unknow option - d etc ...
But Usage Command is:
touch [-c] [-d DATE] FILE [FILE]
BR
die-hard
Yeah, that's weird. It works as you typed it in a regular linux shell, but the busybox on my android gives me the same error. Might be a bug in busybox, or perhaps the date parser in the busybox version is less tolerant on the date format. It may be a config option as well. I know that date/time parsing is very "expensive" in libc and perhaps busybox just doesn't implement it by default.
10x bro,
I solved installing busybox 1.18.0 git
My busybox touch accepts dates in ISO format:
/ # touch -d '2011-1-1 23:1' x
/ # ls -l x
-rw-rw-rw- root shell 0 2011-01-02 00:01 x
Click to expand...
Click to collapse
Hi
I have CM 10.1 with busybox 1.20.2-jb installed. Touch binary doenst have -d option:
Code:
1|[email protected]:/sdcard $ touch --h
touch --h
touch: usage: touch [-alm] [-t time_t] <file>
-t option only accept date in unix timestamp format, but default format ( [[[[cc]yy]MM]dd]hhmm[.ss] ) needed for me.
Can anybody provide touch binary with -d option support or with -t option, that accept date in this format: [[[[cc]yy]MM]dd]hhmm[.ss]?
Second question:
Code:
[email protected]:/ $ awk 'BEGIN {print mktime("1970-01-01 00 00 00")}' <
-5454000
Why awk return -5454000 instead 0?
I tried update busybox to 1.21.0 version, it doesnt help.
memtew said:
Hi
I have CM 10.1 with busybox 1.20.2-jb installed. Touch binary doenst have -d option:
Code:
1|[email protected]:/sdcard $ touch --h
touch --h
touch: usage: touch [-alm] [-t time_t] <file>
-t option only accept date in unix timestamp format, but default format ( [[[[cc]yy]MM]dd]hhmm[.ss] ) needed for me.
Can anybody provide touch binary with -d option support or with -t option, that accept date in this format: [[[[cc]yy]MM]dd]hhmm[.ss]?
Second question:
Code:
[email protected]:/ $ awk 'BEGIN {print mktime("1970-01-01 00 00 00")}' <
-5454000
Why awk return -5454000 instead 0?
I tried update busybox to 1.21.0 version, it doesnt help.
Click to expand...
Click to collapse
Use the touch inside busybox, not the one that comes with the stock rom. Install Busybox from Stericson on your android device. It has also the -d option. You must run it as root, so check that you are superuser if using a script.
Code:
su
busybox touch -c -t YYYYMMDDHHMM[.ss] yourfile
hi,
i have the command working, but is it possible to keep the date and time of each file like "vid_yyyymmdd_hhmmss.mp4" to push it in the command for each file of the folder ?
Thanks.
nobody to help ???
diabolyk said:
hi,
i have the command working, but is it possible to keep the date and time of each file like "vid_yyyymmdd_hhmmss.mp4" to push it in the command for each file of the folder ?
Thanks.
Click to expand...
Click to collapse
You want to rename the files?
scandiun said:
You want to rename the files?
Click to expand...
Click to collapse
no, just change the time of creation of the file
diabolyk34 said:
no, just change the time of creation of the file
Click to expand...
Click to collapse
Don't understand exactly what you want to do.
scandiun said:
Don't understand exactly what you want to do.
Click to expand...
Click to collapse
I have found a command that working well but I should change the files one by one and I would like to find a command which is changing all videos files of a folder.
video name for example : vid_20170717_103251.mp4
need to extract date and time (in the name of the file) to put it in the command.
here the command which is working :
busybox touch -c -t 201707171032 *
and it changes all the files of the folder with the *...
I would like to extract the elements of the name from each file to give it its own date and time.
diabolyk34 said:
I have found a command that working well but I should change the files one by one and I would like to find a command which is changing all videos files of a folder.
video name for example : vid_20170717_103251.mp4
need to extract date and time (in the name of the file) to put it in the command.
here the command which is working :
busybox touch -c -t 201707171032 *
and it changes all the files of the folder with the *...
I would like to extract the elements of the name from each file to give it its own date and time.
Click to expand...
Click to collapse
Ok to do that you need a shell (bash) script. For example this code will get the date in the format you want, now you just need to read it from files and change the timestamp accordingly.
Code:
echo vid_20110717_103251.mp4 | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//'
Test it online here: http://www.learnshell.org/
scandiun said:
Ok to do that you need a shell (bash) script. For example this code will get the date in the format you want, now you just need to read it from files and change the timestamp accordingly.
Code:
echo vid_20110717_103251.mp4 | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//'
Test it online here: http://www.learnshell.org/
Click to expand...
Click to collapse
ok thanks for your help, your code is well working
Is it possible to keep all without the seconds (last 2 digits before .mp4) ?
And after that it should put the result in the command 'busybox touch -c -t result name_of_the_file'
and how to repeat that for each file named 'vid_xxxx' ?
thanks a lot
diabolyk34 said:
ok thanks for your help, your code is well working
Is it possible to keep all without the seconds (last 2 digits before .mp4) ?
And after that it should put the result in the command 'busybox touch -c -t result name_of_the_file'
and how to repeat that for each file named 'vid_xxxx' ?
thanks a lot
Click to expand...
Click to collapse
Go to the folder of the vids with "cd /sdcard/DCIM/Videos" or the appropriate and then execute this:
Code:
for i in * ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
Make sure that in that folder there are only files that have the same exact filename pattern.
scandiun said:
Go to the folder of the vids with "cd /sdcard/DCIM/Videos" or the appropriate and then execute this:
Code:
for i in * ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
Make sure that in that folder there are only files that have the same exact filename pattern.
Click to expand...
Click to collapse
in the folder there is img and videos but if i should put videos on a separate folder i can...
this code will do all i need ? (i think missing just "busybox" in the code)
extract the name of each file without seconds, put for each one the extraction in the command : busybox touch -c -t 201707181200 vid_20170718_120000.mp4 (for example of a file of today at 12 o'clock)
diabolyk34 said:
in the folder there is img and videos but if i should put videos on a separate folder i can...
this code will do all i need ? (i think missing just "busybox" in the code)
extract the name of each file without seconds, put for each one the extraction in the command : busybox touch -c -t 201707181200 vid_20170718_120000.mp4 (for example of a file of today at 12 o'clock)
Click to expand...
Click to collapse
This code will alter only files starting with vid:
Code:
for i in vid* ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
You can try with or without busybox first and see which one works for you.
scandiun said:
This code will alter only files starting with vid:
Code:
for i in vid* ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
You can try with or without busybox first and see which one works for you.
Click to expand...
Click to collapse
thank you very much i will try this in an hour to send you the answer if it's working or not
are you a developper ? cause it seems very hard to know all that...
i have another question, is it possible to put 1 or 2 less than the hour because of GMT ?
201707172000 should be 201707171900...
the answer of the command (not working) is :
touch: invalid date 'VID20170717_2000'
repeat for all lines....
i think it keep too many characters.
characters keeped should be 201707172000 (without "VID" and without "_")
how to delete that from the echo ?

[Request] Dev Help Pretty Please!

Ok I'm on the OTA 2.3.4 from a fresh unlocked 4.1.83 no problems what soever and I'm looking to make a few mods when I saw the link posted for the 2.3.4 HDMI Mirror over at
http://forum.xda-developers.com/showthread.php?t=1169457
I went ahead and ran
adb shell
su
mount -o remount,rw /dev/block/mmcblk0p12 /system
sed -ie s/ro.hdmi.mirror.enable=false/ro.hdmi.mirror.enable=true/g /system/build.prop
mount -o remount,ro /dev/block/mmcblk0p12 /system
cd /etc/init.d
cp startXServer.sh startXServer.bak
(head -n 40 startXServer.bak; echo "if [ ! -e /var/run/noWebtop ]; then"; tail -n 12 startXServer.bak; echo "fi") > startXServer.sh
restart your phone
I read through the command and seemed pretty safe and was excited because the post listed the HDMI Mirror as being in "landscape" mode. Hell yeah right! Well it wasn't, it was the same portrait so I was looking to revert back. Go change the build.prop back for the ro.hdmi.mirror to equal false. No big deal that's easy enough with root explorer. Read through the commands and saw that the startXServer.sh was cp to startXServer.bak. Easy enough just delete the startXServer.sh and rename startXServer.bak to .sh.
Well there is the problem. When i ran the commands the first time didn't work so i went into the build.prop and did a manual change. Then re-ran the bottom half. It seems doing that I over wrote the .bak agan and now both files are exactly the same and have no way of reverting. I have the system, boot, and webtop backed up with an .img but that didn't fix my entertainment center when I plug in an HDMI to the TV. The original commands did a back-up so I didn't double back-up the file.lol
I was wondering if a dev that has a little more command line knowledge, maybe the orginal contents of startXServer.sh, or the actual file could help me out with the revert back and a working entertainment center. The current contents are
if [ ! -e /var/run/noWebtop ]
fi
I'm pretty sure that's the problem, unless someone else sees something I'm missing.
**Edit**
This was solved under the Q&A Section from a earlier post yesterday afternoon. Mods please close if necessary. In case any one needs it see below. I just rewrote the startXServer.sh to contain the following.
#!/bin/sh
#
# startX.sh
#
# This script starts the X server
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=startX
DESC="OSH X Server"
. /lib/lsb/init-functions
#umask 002
log_begin_msg "Starting $DESC: $NAME"
rm -f /tmp/serverauth.*
rm -f /tmp/.X0-lock
rm -fr /tmp/.X11-unix
rm -fr /tmp/.ICE-unix
if [ ! -e /home/adas/.tag_master_reset_ls ]; then
/usr/local/sbin/update-language.pl "en_US.UTF-8"
echo 1 > /home/adas/.tag_master_reset_ls
fi
. /etc/environment
export PATH
export LANG
export DISPLAY
export LD_LIBRARY_PATH
export USER=adas
export HOME=/home/$USER
# new way of starting
if [ $1 = "webtop" ]
then
sudo -u adas -i /usr/bin/startx -- -nolisten tcp -layout HDMI vt2 &
else
sudo -u adas -i /usr/bin/startx /usr/local/bin/xnull -- -nolisten tcp -layout HDMI vt2 &
fi

[HOW TO] Install/Run Android SDK 64 Bit Native on Device

I learned about this here... http://fieldeffect.info/w/NativeCompileSDK
You can install an i386/x86_64 chroot within your existing Debian chroot using qemu-user-static to run the Android SDK on your Android phone/tablet/phablet.
1.
Get yourself a debian chroot, I recommend at least 2gb. I use DebianKit from market.
2.
You will need a X11 desktop environment and a VNC client on your device. I use androidVNC from market.
Here is my working example...
Start your Debian chroot/environment and do...
apt-get install openbox openbox-themes obmenu obconf menu menu-xdg xdg-utils xfonts-base xfonts-terminus* nautilus terminator lxappearance gmrun leafpad man-db hicolor-icon-theme tightvncserver tint2
That gives you a window manager, fonts, filebrowser, terminal emulator, text editor, theme manager, taskbar, and a VNC server.
Now lets get some GTK engines and libraries....
apt-get install gtk2-engines-auroa gtk2-engines-murrine gtk2-engines-oxygen gtk2-engines-pixbuf libgtk2.0-bin gtk3-engines-oxygen gtk3-engines-unico libgtk-3-bin
Now 7zip to handle zips and archives comfortably(put non-free in your apt sources.list)...
apt-get install p7zip p7zip-full p7zip-rar zip unzip
##The Android SDK manager, qemu, and multistrap##
apt-get install ant file openjdk-6-jre openjdk-6-jdk qemu-user-static libswt-gtk-3-java libswt-cairo-gtk-3-jni
3.
Now we can build a small x86_64 rootfs using multistrap
multistrap can use a config, have mine...
http://db.tt/hS5j3wg
Copy multistrap.conf straight into your working(pwd) directory....
cp /sdcard/Download/multistrap.conf .
Do this to avoid multistrap complaining later...
cat multistrap.conf >mstrap
mkdir /data/mnt
Determine size of rootfs for loop image..
du -hs /data/mnt/
Now make an image for x86_64 chroot
dd if=/dev/zero of=/sdcard/64bit.img bs=$(( 0x100000 )) count=YOUR IMAGE SIZE
That byte size makes your image slightly larger than the count value in Mb, for example count=78 will write 82Mb image.
mkfs.ext2 /sdcard/64bit.img
tune2fs -c0 /sdcard/64bit.img
mkdir /data/tmp
busybox mount -o loop /sdcard/64bit.img /data/tmp/
cp -r /data/mnt/* /data/tmp/
umount /data/tmp
rm -r /data/tmp/
rm -r /data/mnt/
mkdir /data/mnt
busybox mount -o loop /sdcard/64bit.img /data/mnt/
5.
Now the environment is set up and mounted, at this point install the SDK
Aim your browser to http://developer.android.com/sdk/index.html
Select "Linux" from "SDK Tools Only", thats the last thing at the bottom of the list.
cp /sdcard/Download/android-sdk_r21.0.1-linux.tgz .
7z x android-sdk_r21.0.1-linux.tgz russosv
7z x android-sdk_r21.0.1-linux.tar
Now we need a couple goodies from http://fieldeffect.info/w/NativeCompileAPK ##--Thanks to russosv from FeildEffect
These are edited from original....
#!/bin/bash
QEMU=/usr/bin/qemu-x86_64-static
64CHROOT=/data/mnt/
case "$1" in
mklinks)
if [ ! -e "./64BIT" ]; then
mkdir ./64BIT
fi
for i in $(file ./* | grep "ELF 32" | awk '{print $1}' | sed s/://g | sed s/[./]//g); do
echo "Moving $i..."
mv $i ./64BIT
ln -s ~/bin/run-64-link $i
done-
;;
*)
$QEMU $64CHROOT/lib64/ld-linux-x86_64.so.2 --library-path $64CHROOT/lib:$64CHROOT/usr/lib:$64CHROOT/usr/share/perl/5.12.4/unicore/lib:$64CHROOT/var/lib:$64CHROOT/lib/x86_64-linux-gnu:$64CHROOT/usr/lib/x86_64-linux-gnu [email protected]
;;
esac
Copy that to run-64, then...
chmod 755 run64
cp run-64 /usr/bin/
One more...
echo $(dirname $0)/64BIT/$(basename $0) [email protected]
/usr/bin/run-i386 $(dirname $0)/64BIT/$(basename $0) [email protected]
Make that run-64-link
chmod 755 run-64-link
cp run-64-link /usr/bin/
5b.
Now launch VNC server
tightvncpasswd
tightvncserver
killall Xtightvnc
cat >.vnc/xstartup<<EOF
tint2 &
terminator &
openbox-session
EOF
tightvncserver
export DISPLAY=:1
6.
Now launch the VNC client I mentioned earlier, should connect with 127.0.0.1:5901 and your password you set.
Go back to terminal or use the one launched on X11 to do...
sh android-sdk-linux/tools/android
Install at least one api.
If all went well you can now go around "debugging" yours and your friends Android devices over wifi now.
For an example, and to see it work do....
svc wifi disable(or enable) ##this turns off/on wifi
setprop service.adb.tcp.port 5555(or -1) ##this turns on/off adb over network
stop adbd
start adbd
adb connect 127.0.0.1(yours) or any other adbd addy listening on your network,
Have fun
Never did a "how to" before, go easy and I'll make corrections and answer things. Thanks for reading. Leave feedback.
Potential necro post but I believe the information is still currently valid and not readily available on searches. I've looked variations of this up for years with no luck until I hit the right search terms.
bump, and thanks.
can't believe there's no comments.
I know it's a slower than real-64-bit-pc method but not all of us have access to new hardware... or pc's. Maybe a novelty, still cool and useful if you've got the time to let the slower hardware compile.
you have preserved the scripts, original link is dead.
here is the Internet Wayback Machine cache of the original circa 2012 for reference.
http://web.archive.org/web/20120502044700/http://fieldeffect.info/w/NativeCompileAPK
appreciate you sharing.

Guide: Fix WhatsApp Images mess after restoring backup

Hey there
Thought this might help some of you finding yourself in a huge mess because WhatApp restores all its media with the date the restore takes place. I wrote a little shellscript you can run in "adb shell". Just paste it into the shell and run it inside WhatsApps Folders.
In "WhatsApp Images" and it's subfolder "Sent" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^IMG-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
For "WhatsApp Animated Gifs" and "WhatsApp Video" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^VID-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
Keep the following in mind:
- This code works only if your version of Android allows you to change the modified date of files without root. As far as I know this is the case since Andoid 9
- This code doesn't work if you have files with a WA-Number higher than 0599 as my script doesn't take care to match the number with a proper timeformat.
- This code changes the last modified date of your files like this:
Filename: IMG-20190915-WA0039.jpg
Timestamp: 201909150003.09 -> 20190915 00:03:09
Feedbacks and comments welcome
Greets Air

Run bash script app

I' m trying to run a bash script.
I have a script and that script download 3 other scripts, and then, run them.
The first script, is the script where downloading 3 other scripts and running them.
The second script, is an example of the 3 other scripts.
So, which is the easiest way to do that ?
Is there any application where can do that ?
I use these scripts on android tv boxes.
The tv boxes are not rooted.
Also, i have an error with "wget: bad address"
Bash:
#!/bin/bash
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
sleep 1;
wget http://domain.com/files/script_2.sh -O /sdcard/scripts/script_2.sh
sleep 1;
wget http://domain.com/files/script_3.sh -O /sdcard/scripts/script_3.sh
sleep 1;
sh ./sdcard/scripts/script_1.sh
sleep 1;
sh ./sdcard/scripts/script_2.sh
sleep 1;
sh ./sdcard/scripts/script_3.sh
notify-send "Finish"
exit
Bash:
#!/bin/bash
wget https://domain.com/files/name.txt -O /sdcard/scripts/1.txt
cat 1.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 1_.txt
a=$(cat 1_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$a\[email protected]" /sdcard/scripts/file/filename1
sleep 2 ;
wget https://domain.com/files/name.txt -O /sdcard/scripts/2.txt
cat 2.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 2_.txt
b=$(cat 2_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$b\[email protected]" /sdcard/scripts/file/filename2
sleep 2 ;
find /sdcard/scripts/file/ -name "*.m" -printf '%T+ %p\n' | sort -r | xargs cat > /sdcard/scripts/file/filename.new
sleep 1 ;
sed -i '1i word' /sdcard/scripts/file/filename.new
sed -i '2i word' /sdcard/scripts/file/filename.new
sed -i '3i word' /sdcard/scripts/file/filename.new
sed -i '4i word' /sdcard/scripts/file/filename.new
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
DSA said:
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
Click to expand...
Click to collapse
Sorry, i forgot to say that the "domain.com" is an example. I use correct domain in my script. Just i hide it in post, because i wouldn't to share it.
The script in linux works fine.
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
jwoegerbauer said:
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
Click to expand...
Click to collapse
Didn't work. Same error
"wget: bad address"

Categories

Resources