• Different response while executing Python Script from terminal and via

    From mglowinski93@gmail.com@21:1/5 to All on Fri Aug 31 03:37:32 2018
    Hi,
    i've problem with Apache2. It is not executing properly Python Scripts which includes "sudo" command. Those scripts are working fine while running from terminal (as a "pi" user).

    Apache2 is running also "pi" user.
    Response for ps aux | grep apache2 command:
    Hide Copy Code

    root 409 0.0 0.4 7544 3824 ? Ss 18:48 0:00 /usr/sbin/apache2 -k start
    pi 410 0.0 0.3 7292 3036 ? S 18:48 0:00 /usr/sbin/apache2 -k start
    pi 411 0.0 0.4 231032 3872 ? Sl 18:48 0:01 /usr/sbin/apache2 -k start
    pi 412 0.0 0.4 231032 3872 ? Sl 18:48 0:01 /usr/sbin/apache2 -k start
    pi 1920 0.0 0.0 4372 556 pts/0 S+ 20:17 0:00 grep --color=auto apache2



    Python scripts are executable for every user:
    Hide Copy Code

    -rwxrwxr-x 1 pi pi 1251 Aug 27 16:46 checkDisks.py
    -rwxrwxr-x 1 pi pi 1650 Aug 30 05:52 checkDownload.py
    -rwxrwxr-x 1 pi pi 1969 Aug 10 08:38 checkUSB.py
    -rwxrwxr-x 1 pi pi 725 Aug 27 13:31 createUSB.py
    drwxrwxr-x 3 pi pi 4096 Aug 30 05:14 current
    -rwxrwxrwx 1 pi pi 522 Aug 27 20:25 deleteFiles.py
    -rwxrwxrwx 1 pi pi 627 Aug 9 08:33 downloadLatest.py
    drwxrwxr-x 34 pi pi 4096 Jul 31 15:42 dss-testautomation
    drwxrwxr-x 7 pi pi 4096 May 3 14:46 dss-update-tester
    -rw--w---- 1 pi pi 28 Aug 27 19:53 nohup.out
    -rwxrwxrwx 1 pi pi 1214 Aug 27 20:41 prepareSpace.py
    drwxrwxr-x 3 pi pi 4096 May 3 11:02 testserver
    -rw-rw-r-- 1 pi pi 104 Aug 9 16:19 USB_lock
    -rwxrwxrwx 1 pi pi 2187 Aug 20 14:29 usbOFF.py
    -rwxrwxrwx 1 pi pi 3334 Aug 30 18:47 usbON.py
    drwxrwxr-x 5 pi pi 4096 May 3 14:39 webpy_server



    /var/log/apache2.error.log:
    Hide Expand Copy Code

    [Thu Aug 30 06:25:04.010021 2018] [mpm_event:notice] [pid 421:tid 1996357632] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 06:25:04.010214 2018] [core:notice] [pid 421:tid 1996357632] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 06:29:27.351568 2018] [mpm_event:notice] [pid 421:tid 1996357632] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 06:29:30.780150 2018] [mpm_event:notice] [pid 425:tid 1996349440] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 06:29:30.782850 2018] [core:notice] [pid 425:tid 1996349440] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 07:11:05.987870 2018] [mpm_event:notice] [pid 425:tid 1996349440] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 07:11:09.764342 2018] [mpm_event:notice] [pid 407:tid 1996001280] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 07:11:09.766669 2018] [core:notice] [pid 407:tid 1996001280] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 07:14:13.321922 2018] [mpm_event:notice] [pid 407:tid 1996001280] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 07:14:16.745765 2018] [mpm_event:notice] [pid 412:tid 1996087296] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 07:14:16.747934 2018] [core:notice] [pid 412:tid 1996087296] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 07:20:01.962704 2018] [mpm_event:notice] [pid 412:tid 1996087296] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 07:20:05.697280 2018] [mpm_event:notice] [pid 410:tid 1995591680] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 07:20:05.699445 2018] [core:notice] [pid 410:tid 1995591680] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 08:48:14.215742 2018] [mpm_event:notice] [pid 410:tid 1995591680] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 08:48:17.779856 2018] [mpm_event:notice] [pid 407:tid 1996382208] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 08:48:17.782313 2018] [core:notice] [pid 407:tid 1996382208] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 09:56:42.876253 2018] [mpm_event:notice] [pid 411:tid 1995579392] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 09:56:42.879043 2018] [core:notice] [pid 411:tid 1995579392] AH00094: Command line: '/usr/sbin/apache2'
    [Thu Aug 30 18:48:30.844159 2018] [mpm_event:notice] [pid 411:tid 1995579392] AH00491: caught SIGTERM, shutting down
    [Thu Aug 30 18:48:34.752957 2018] [mpm_event:notice] [pid 409:tid 1996111872] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
    [Thu Aug 30 18:48:34.755767 2018] [core:notice] [pid 409:tid 1996111872] AH00094: Command line: '/usr/sbin/apache2'


    I checked response for "mount" command. There are different results while executing this from terminal and different while executing it via Apache2.

    Any tips what can be wrong?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to mglowinski93@gmail.com on Fri Aug 31 19:25:21 2018
    In comp.infosystems.www.servers.unix, <mglowinski93@gmail.com> wrote:
    Hi,
    i've problem with Apache2. It is not executing properly Python Scripts which includes "sudo" command. Those scripts are working fine while running from terminal (as a "pi" user).

    Apache2 is running also "pi" user.

    That's not really a web server problem. You've encountered this while
    using a webserver, but the fix isn't in a change to the web server
    config.

    /var/log/apache2.error.log:

    [snip]

    I see no output from your scripts there, just normal apache restart
    messages.

    I checked response for "mount" command. There are different results while executing this from terminal and different while executing it via Apache2.

    Any tips what can be wrong?

    1. Understand your tools well enough to get proper error messages out
    of them.
    2. Understand the Unix environment: how is running from a terminal
    different from running from a server? What things should you check
    for when the two cases work differently?
    3. Learn how to ask questions better. (What exactly is your script
    trying do do? How are the results different?)
    4. Possibly: Understand the Unix permission model.

    You might find better luck in a python group (eg comp.lang.python),
    the Pi group (comp.sys.raspberry-pi), or a shell programming group
    (eg comp.unix.shell).

    Elijah
    ------
    can't debug what he can't see

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)