1

can someone take a look over this script? I want to add it in a sh file. When I connect my ethernet adapter I don't want enter all commands again. I just want to execute it from shell. Is this correct?

#!/bin/sh
ip link set eth0 up
sleep 1;
ip addr add 192.168.178.50/24 dev eth0
sleep 1;
ip route add default via 192.168.178.1 dev eth0
sleep 1;
ndc network create 1
sleep 1;
ndc network interface add 1 eth0
sleep 1;
ndc resolver setnetdns 1 8.8.8.8 8.8.4.4
sleep 1;
ndc network default set 1

When I enter the commands directly into terminal emulator ir works, when I execute the script with #sh filename.sh I get error.

The second problem is, my file in root folder isn't here anymore after reboot.

5
  • question can be answered by testing yourself. shebang is #!/system/bin/sh for android
    – alecxs
    Commented Feb 12, 2020 at 8:19
  • 1
    @alecxs /bin can be a symlink: android.googlesource.com/platform/system/core/+/… Commented Feb 13, 2020 at 0:26
  • it does not work as espected. when I enter the commands directly into terminal emulator ir works, when I execute the script with #sh filename.sh I get error. The second problem is, my file in root folder isn't here anymore after reboot.
    – user314662
    Commented Feb 13, 2020 at 13:07
  • Irfan Latif, thanks for your help. But If I use ethernet seldom, so its enough to copy and paste the commands over ADB Wifi. The ndc commands work, but with ifconfig you only configure your IP and netmask. The gateway works also over ndc, the command is ndc network route add <netid> eth0 0.0.0.0/0 0.0.0.0 (the last 0.0.0.0 stands for your gateway IP).
    – user314662
    Commented Feb 18, 2020 at 17:09

0

You must log in to answer this question.

Browse other questions tagged .