Creating a Script

I know it may seem basic, but I still couldn't solve this problem. I'm actually trying to create a simple script to run during system boot. I already managed to connect to the device using adb and ssh tools, but when logged in as root some commands (many of them), like 'nano', don't work! I get the message "sh: nano: inaccessible or not found".
So how am I supposed to solve this? Tks

Comments

  • Hi @celotronics
    There is no nano. The Linux kernel which is used for Android doesn't have all the things a full Linux kernel has. You should create the script and just push it via adb to the device.
    It used to work like this: https://emteria.com/kb/device-configuration-style-initd-scripts
    But on Android 14 there might be more restrictions. What is your script roughly supposed to do?

  • edited February 22

    Ah, understood! thank you for your attention!
    I was thinking about some possibilities like this using adb, but I thought I was doing something wrong.
    As for my script, I'm doing EXACTLY what is in this tutorial that you sent me the link, but i'm having some troubles.
    My script (the same as the link) was moved to /data/init.d/ successfully, but when I restart the system it doesn't even create the /gpio5/ directory in /sys/class/gpio/. I think it might be a permissions issue, but my attempts haven't worked.
    Furthermore, I would also like to know how to read the value of a digital port.

  • @smieschek
    Any tip or idea?

  • Hi @celotronics

    I ran into a similar issue, so maybe my solution works for you as well.
    The script I made was generated on windows and transferred to Emteria through the adb.
    But because of this the line endings were in the wrong format.

    So after transferring the script I applied the following commands to it:
    chown root:system /data/init.d/yourscript
    chmod 0755 /data/init.d/yourscript
    dos2unix /data/init.d/yourscript

    I also added the following line to check if the script ran:
    echo "Script executed" > /storage/emulated/0/Download/autostart.log

  • It worked, thank you SO MUCH @Futience!!!!
    Very well observed.

Sign In or Register to comment.