We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

static ethernet



  • How to setup static IP address for Ethernet LAN connection. I have given below way. Is this correct
    ?
    config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.1.60'
    option netmask '255.255.255.0'
    option ip6assign '60'



  • @Nagarjuna-Reddy Yes it is correct, this is how I configure my device for flashing:

    config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.1.188'
    option netmask '255.255.255.0'
    option ip6assign '60''



  • @crispyoz
    I have enabled PPP communication connecting to GSM modem using chat comgt (hologram) and meantime i have to ping office host IP address. yes, I was able to pinging after added static IP in /etc/config/network file. I want to run some python scripts after boot for that i have added scripts in /rc.local. After reboot scripts are not running and same time reboot command also not working. So what could be the issue?

    start-stop-deamon -b -S -x python /root/hello.py // i have given this way in rc.local



  • @Nagarjuna-Reddy :

    Here is my script:
    #!/usr/bin/env python3
    import time
    count = 100
    while count != 0:
    time.sleep(1)
    count -= 1

    Please see the following observation:

    root@Omega-745F:/tmp# free
    total used free shared buffers cached
    Mem: 124808 55340 69468 348 5760 26592
    -/+ buffers/cache: 22988 101820
    Swap: 0 0 0

    root@Omega-745F:/tmp# start-stop-daemon -b -S -x /tmp/hello.py
    root@Omega-745F:/tmp# free
    total used free shared buffers cached
    Mem: 124808 57252 67556 348 5760 26592
    -/+ buffers/cache: 24900 99908
    Swap: 0 0 0

    root@Omega-745F:/tmp# start-stop-daemon -b -S -x /tmp/hello.py
    root@Omega-745F:/tmp# free
    total used free shared buffers cached
    Mem: 124808 59248 65560 348 5760 26592
    -/+ buffers/cache: 26896 97912
    Swap: 0 0 0

    root@Omega-745F:/tmp# start-stop-daemon -b -S -x /tmp/hello.py
    root@Omega-745F:/tmp# free
    total used free shared buffers cached
    Mem: 124808 61276 63532 348 5760 26592
    -/+ buffers/cache: 28924 95884
    Swap: 0 0 0

    root@Omega-745F:/tmp# ps |grep python
    4985 root 5116 S python3 /tmp/hello.py
    4989 root 5116 S python3 /tmp/hello.py
    4993 root 5116 S python3 /tmp/hello.py
    4996 root 1216 S grep python

    Obviously, -S is not working, but the scripts exit after 100 seconds.

    Thanks..



  • @Nagarjuna-Reddy @tjoseph1

    Why not just run a bash script in the background and the script could execute your python code.

    Here is a simple bash (ash) script:

    #!/bin/ash
    while :
    do
    echo Looping
    sleep 3
    done

    In your rc.local you can execute it in the background:

    ./test_loop.sh &

    exit 0



  • @Nagarjuna-Reddy :
    I just modified the one in my above post:

    root@Omega-745F:/# cat /etc/rc.local
    # Put your custom commands here that should be executed once
    # the system init finished. By default this file does nothing.
    start-stop-daemon -b -S -x /root/hello.py
    exit 0

    root@Omega-745F:/# cat /root/hello.py
    #!/usr/bin/env python3
    import os
    import time

    if os.path.exists("/tmp/hello.run"):
    exit()
    else:
    f = open("/tmp/hello.run", 'w')
    f.close()

    count = 100
    while count != 0:
    time.sleep(1)
    count -= 1

    os.remove("/tmp/hello.run")

    Reboot.. the python scripts executes at the boot from rc.local, it seems

    root@Omega-745F:/# ps |grep python
    1533 root 5124 S python3 /root/hello.py
    1976 root 1216 S grep python

    root@Omega-745F:/# ls -l /tmp/hello.run
    -rw-r--r-- 1 root root 0 Sep 14 19:33 /tmp/hello.run

    root@Omega-745F:/# ps |grep python
    1533 root 5124 S python3 /root/hello.py
    1981 root 1216 S grep python

    root@Omega-745F:/# ls -l /tmp/hello.run
    -rw-r--r-- 1 root root 0 Sep 14 19:33 /tmp/hello.run

    After 100 seconds..

    root@Omega-745F:/# ps |grep python
    1984 root 1216 S grep python

    root@Omega-745F:/# ls -l /tmp/hello.run
    ls: /tmp/hello.run: No such file or directory

    I do not know how -S can be seriously implemented from python as laid out in "man start-stop-daemon":
    <<
    start-stop-daemon is used to control the creation and termination of system-level processes. Using one of the matching options, start-stop-daemon can be configured to find existing instances of a running process.
    <<

    Once you reach there, post your control code, please.

    You can probably use python's try.. except..finally to take care of all the situations at runtime events ?



  • @Nagarjuna-Reddy :

    You might want to follow @crispyoz's recommendation. Didn't notice @crispyoz's post, my bad.

    Thanks..



  • @tjoseph1 There is usually more than one solution šŸ™‚ I just prefer bash scripting over python since it is more light weight and has less dependencies. When I hit a wall with scripting I would usually write in C, mainly because I really don't like python.



  • @crispyoz :

    Me either.. nor python nor js when it comes to microcontrollers. I have done some pandas, though..
    There must be a reason for C's rating is on the rising, recently:
    https://tiobe.com/tiobe-index/ . But, that is my personal view.

    Thanks ..



  • @tjoseph1 Because all this JS and Python encourages poor code structure. C and C++ in particular encourage structured code. Now watch the flame wars commence šŸ™‚

    I'm not sure the survey in your link has much veracity given that it places ASM above Objective C, if that were the case I'd probably come out of semi-retirement.



  • @crispyoz
    sir, i have connected ethernet cable directly from my PC to onion. for that, i have given static IP address in onion
    config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.1.60'
    option netmask '255.255.255.0'

    and meantime i am running PPP connection(GSM Modem) using chat comgt. the problem is when i have added python and shell scripts are in /rc.local files are not running in the background and same time reboot function also not working. what could be the issue.?



  • <<
    the flame wars commence
    <<
    Like I said, that was my personal view.

    IEEE gives different rating:
    https://spectrum.ieee.org/computing/software/the-top-programming-languages-2019 šŸ™‚

    I am sure you might have noticed, mentioned by TOIBE:
    <<
    The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.
    <<
    End of the day, if ones loves the language and tools one uses, and the solution works as designed/expected..then all is well.

    Thanks..



  • @tjoseph1 I agree with you, I use the best tool for the job at hand and after 35+ years of writing software I've seen a lot of fads. Structure, structure, structure.

    My comment re the survey is I'm a skeptic at heart, unless I know what the question was, I'll add a pinch of salt to the answer.



  • @Nagarjuna-Reddy there are a few questions there.

    "shell scripts are in /rc.local files are not running in the background"

    rc.local is in /etc maybe you can post your rc.local so we can look at it, just ###### out anything you can't share.

    To assist in debugging scripts that run in the background ..... or fail to run in the background .... I suggest you uses some logging. To revisit my test script, you can add some new lines for logging:


    #!/bin/ash
    while :
    do
    echo "Looping" >> /tmp/loop.log
    sleep 3
    echo "After sleeping" >> /tmp/loop.log
    done

    echo "I just bailed out" >> /tmp/loop.log


    After a minute or so run cat /tmp/loop.log then you can see if the loop actually ran and how many times.



  • @crispyoz :
    Thanks.. if its that, ASM happened to be on the top..because there were more searches on ASM, than ObjC..that would make you smile šŸ™‚ ?



  • @tjoseph1 Could also be typos in searches šŸ™‚



  • @crispyoz :
    Possible..but between ASM n ObjC? I for one have searched ASM..but never ObjC.. & I guess veterans like you, either do not, or if you do, it would be more on the ASM side šŸ™‚



  • @tjoseph1 I don't search for ASM, but I might search for "why NeXT failed" and by implication, why we have objective c



  • @crispyoz :
    Why warp failed is another mystery. Warp4 with the tabbed UI was much better/stable than w95. Why mips origin/octane/onyx failed after leading the innovation at ilm, pixar is another mystery..may be those were ahead of their right time.



  • @tjoseph1 Don't start me on that topic. Why do you think Billy and his babe are donating toilets to the huddled masses? Guilt has a way of gnawing away at your soul.



Looks like your connection to Community was lost, please wait while we try to reconnect.