Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Problem with Script in /dispatcher.d

  1. #1
    Join Date
    May 2011
    Location
    3rd Rock from the Sun
    Posts
    29

    Default Problem with Script in /dispatcher.d

    I am having problem running a Script from /etc/NetworkManager/dispatcher.d. (I have openSuse13.1 Xfce 64bit).
    The script is to login to my ISP; without the script I have to login via 'java enabled' browser.

    I have checked the NetworkManager log. Earlier (couple of days ago when suse forum was not available) the log reported that the script did not have necessary permissions, or permission denied.
    However, today the log does not have any entry regarding /dispatcher.d.

    I still cannot run the script, which is in /etc/NetworkManager/dispatcher.d/autologinscript.

    Here is the script:
    Code:
    #!/bin/sh
    IFACE=$1
    ACTION=$2
    
    if [ "$IFACE" = "eth0" ]; then
            if [ "$ACTION" = "up" ]; then
        curl -d "function=ExecuteLogin&user=username&pwd=password&remember=false&timestamp=xxx941xxx90xx" http://ISPurl/Ajax.php  
            fi
    fi
    I can login with my ISP when I run the 'curl' command from the Terminal.
    The script as such is working in Arch Linux, which is also installed on the same PC.

    Currently 'root' owns the said script file.

    Any ideas what I am missing here? or whatever I am not doing correctly...

    Regards...

  2. #2
    Join Date
    Jun 2008
    Location
    Kansas City Area, Missouri, USA
    Posts
    7,236

    Default Re: Problem with Script in /dispatcher.d

    On 01/11/2014 08:46 PM, fantab wrote:
    >
    > I am having problem running a Script from
    > /etc/NetworkManager/dispatcher.d. (I have openSuse13.1 Xfce 64bit).
    > The script is to login to my ISP; without the script I have to login via
    > 'java enabled' browser.
    >
    > I have checked the NetworkManager log. Earlier (couple of days ago when
    > suse forum was not available) the log reported that the script did not
    > have necessary permissions, or permission denied.
    > However, today the log does not have any entry regarding /dispatcher.d.
    >
    > I still cannot run the script, which is in
    > /etc/NetworkManager/dispatcher.d/autologinscript.
    >
    > Here is the script:
    >
    > Code:
    > --------------------
    > #!/bin/sh
    > IFACE=$1
    > ACTION=$2
    >
    > if [ "$IFACE" = "eth0" ]; then
    > if [ "$ACTION" = "up" ]; then
    > curl -d "function=ExecuteLogin&user=username&pwd=password&remember=false&timestamp=xxx941xxx90xx" http://ISPurl/Ajax.php
    > fi
    > fi
    >
    > --------------------
    >
    >
    > I can login with my ISP when I run the 'curl' command from the Terminal.
    > The script as such is working in Arch Linux, which is also installed on
    > the same PC.
    >
    > Currently 'root' owns the said script file.
    >
    > Any ideas what I am missing here? or whatever I am not doing
    > correctly...


    The first thing I see is that you should never assume the environment in a
    script like this. It is possible that /usr/bin/ is not in the path. Always use a
    full path for any command.

    Secondly, on openSUSE, sh is also found in /usr/bin/. You should change the
    shebang (first line).

    Lastly, make sure that the execute bits are set in the script's permissions.


  3. #3
    Join Date
    May 2011
    Location
    3rd Rock from the Sun
    Posts
    29

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by lwfinger View Post

    The first thing I see is that you should never assume the environment in a
    script like this. It is possible that /usr/bin/ is not in the path. Always use a
    full path for any command.

    Secondly, on openSUSE, sh is also found in /usr/bin/. You should change the
    shebang (first line).

    Lastly, make sure that the execute bits are set in the script's permissions.
    Thanks.
    So:
    1. I must use "#!/usr/bin/sh"?
    2. I don't quite understand 'execute bit are set in the script's permissions"... could you please elaborate on this.

  4. #4
    Join Date
    Sep 2012
    Posts
    7,096

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by lwfinger View Post
    Secondly, on openSUSE, sh is also found in /usr/bin/. You should change the
    shebang (first line).
    Code:
    bor@opensuse:~> LC_ALL=C ll /bin/sh
    lrwxrwxrwx 1 root root 4 Dec 10 17:04 /bin/sh -> bash

  5. #5
    Join Date
    Sep 2012
    Posts
    7,096

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by fantab View Post
    Any ideas what I am missing here?
    Show output of "ls -l /etc/NetworkManager/dispatcher.d/autologinscript"

  6. #6
    Join Date
    May 2011
    Location
    3rd Rock from the Sun
    Posts
    29

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by arvidjaar View Post
    Show output of "ls -l /etc/NetworkManager/dispatcher.d/autologinscript"
    Code:
    -rwxr-xr-x 1 root root 214 Jan 12 12:49 /etc/NetworkManager/dispatcher.d/autologinscript
    Any ideas?

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,761

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by fantab View Post
    1. I must use "#!/usr/bin/sh"?
    You must use the place where the interpreter you want to use is.
    When your script is a bash script, it is /bin/bash
    When your script is a POSIX shell script, it is /usr/bin/sh
    It is you that should know what scripting language you have written the script in.
    And I found the correct places by using:
    Code:
    henk@boven:~> which bash
    /bin/bash
    henk@boven:~> which sh
    /usr/bin/sh
    henk@boven:~>
    But in the POSIX shell case you can also use /bin/sh because that is a link
    Code:
    henk@boven:~> l /bin/sh
    lrwxrwxrwx 1 root root 4  3 aug 17:29 /bin/sh -> bash*
    henk@boven:~>
    BTW. Do NOT jump to the conclusion that the link shows that sh is the same as bash. It is not. It is only handled by the same program, but that program knows how it is called (argument 0) and it will handle a script according to the definitions that belong to that call.
    Henk van Velden

  8. #8
    Join Date
    Sep 2012
    Posts
    7,096

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by fantab View Post
    Any ideas?
    Did you try full path to curl as was already suggested? /usr/bin/curl instead of curl?

  9. #9

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by fantab View Post
    Here is the script:
    Code:
    #!/bin/sh
    IFACE=$1
    ACTION=$2
    
    if [ "$IFACE" = "eth0" ]; then
            if [ "$ACTION" = "up" ]; then
        curl -d "function=ExecuteLogin&user=username&pwd=password&remember=false&timestamp=xxx941xxx90xx" http://ISPurl/Ajax.php  
            fi
    fi
    Is your network interface really eth0?
    On 13.1 it would be named differently by default, see http://www.freedesktop.org/wiki/Soft...nterfaceNames/

    Run f.e. "/sbin/ifconfig" to check.

  10. #10
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,761

    Default Re: Problem with Script in /dispatcher.d

    Quote Originally Posted by wolfi323 View Post
    Is your network interface really eth0?
    On 13.1 it would be named differently by default, see http://www.freedesktop.org/wiki/Soft...nterfaceNames/

    Run f.e. "/sbin/ifconfig" to check.
    I basicaly had the same question, but as he says (but he does not prove that by showing!):
    I can login with my ISP when I run the 'curl' command from the Terminal.
    in his first post, I didn't. (But I wondered)
    Henk van Velden

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •