Home of the Squeezebox™ & Transporter® network music players.
Page 3 of 8 FirstFirst 12345 ... LastLast
Results 21 to 30 of 75
  1. #21
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by paul- View Post
    Likely need to reference the full path to the binary.

    /usr/local/sbin/uhubctl
    I tried
    Code:
    #!/bin/sh
    #----------------------------------------------------------------------------------------
    # Script for turning RPi3 USB output on/off when Squeezelite player is turned on/off.
    # This script requires that extension uhubctl.tcz is installed.
    # Enter the path to this "Power On/Off Script" on the pCP Squeezelite Settings page.
    # https://github.com/mvp/uhubctl#raspberry-pi-b2b3b
    #----------------------------------------------------------------------------------------
    # squeezelite -S /home/tc/usb-power-on-off.sh
    # 
    # squeezelite sets $1 to:
    #	0: off
    #	1: on
    #----------------------------------------------------------------------------------------
    
    case $1 in
        0) /usr/local/sbin/uhubctl -l 1-1 -p 4 -a 0 >/dev/null 2>&1 ;;
        1) /usr/local/sbin/uhubctl -l 1-1 -p 4 -a 1 >/dev/null 2>&1 ;;
    esac
    with no luck. How can I tell the state of squeezelite ($1)?

  2. #22
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by paul- View Post
    Likely need to reference the full path to the binary.

    /usr/local/sbin/uhubctl
    I also tried the built in "powerscript.sh" which sends the $1 state to an ssh terminal and that doesn't work either. Am I wrong in expecting that toggling the power of piCorePlayer in Material skin or the Default skin should change the state of $1 and display it in the terminal?

  3. #23
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,137
    Quote Originally Posted by slartibartfast View Post
    I also tried the built in "powerscript.sh" which sends the $1 state to an ssh terminal and that doesn't work either. Am I wrong in expecting that toggling the power of piCorePlayer in Material skin or the Default skin should change the state of $1 and display it in the terminal?
    Just in case the arg num is wrong you should dump all args values into a file - something like

    echo "All Arguments values:" $@ >/tmp/allargs.txt

  4. #24
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by bpa View Post
    Just in case the arg num is wrong you should dump all args values into a file - something like

    echo "All Arguments values:" $@ >/tmp/allargs.txt
    Do you mean edit the script file or is there another way to do it?

    Sent from my Pixel 3a using Tapatalk

  5. #25
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by bpa View Post
    Just in case the arg num is wrong you should dump all args values into a file - something like

    echo "All Arguments values:" $@ >/tmp/allargs.txt
    I tried running that at the command line and it doesn't list any arguments in the file. How do I get it to dump the arg values?

    Sent from my Pixel 3a using Tapatalk

  6. #26
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,137
    My suggestion is in the script.

    The following is my version which just creates lots of output to shows which parts of script are executed.
    Squeezelite V1.9.7-1283 was tested on a Rasbian Buster
    Squeezelite is standard Ralphy and has GPIO build option.
    Run from command line with "-S /home/pi/myscript.sh"

    Code:
    #!/bin/sh
    #----------------------------------------------------------------------------------------
    # Script for turning RPi3 USB output on/off when Squeezelite player is turned on/off.
    # This script requires that extension uhubctl.tcz is installed.
    # Enter the path to this "Power On/Off Script" on the pCP Squeezelite Settings page.
    # https://github.com/mvp/uhubctl#raspberry-pi-b2b3b
    #----------------------------------------------------------------------------------------
    # squeezelite -S /home/tc/usb-power-on-off.sh
    # 
    # squeezelite sets $1 to:
    #	0: off
    #	1: on
    #----------------------------------------------------------------------------------------
    NOW=$(date +"%m-%d-%Y %T")
    echo "---  $NOW ---" >>/tmp/powerlog.txt
    echo "Args: " "$@" >>/tmp/powerlog.txt
    case $1 in
        0) echo "Arg dollar 1 value 0 " >>/tmp/powerlog.txt ;;
        1) echo "Arg dollar 2 value 1 " >>/tmp/powerlog.txt ;;
    esac
    
    echo "---- End run ---- " >>/tmp/powerlog.txt
    Toggling power button on WebUI for player
    Code:
    ---  11-15-2020 11:49:12 ---
    Args:  0
    Arg dollar 1 value 0 
    ---- End run ---- 
    ---  11-15-2020 11:49:12 ---
    Args:  1
    Arg dollar 2 value 1 
    ---- End run ---- 
    ---  11-15-2020 11:49:13 ---
    Args:  0
    Arg dollar 1 value 0 
    ---- End run ---- 
    ---  11-15-2020 11:49:13 ---
    Args:  1
    Arg dollar 2 value 1 
    ---- End run ----

  7. #27
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by bpa View Post
    My suggestion is in the script.

    The following is my version which just creates lots of output to shows which parts of script are executed.
    Squeezelite V1.9.7-1283 was tested on a Rasbian Buster
    Squeezelite is standard Ralphy and has GPIO build option.
    Run from command line with "-S /home/pi/myscript.sh"

    Code:
    #!/bin/sh
    #----------------------------------------------------------------------------------------
    # Script for turning RPi3 USB output on/off when Squeezelite player is turned on/off.
    # This script requires that extension uhubctl.tcz is installed.
    # Enter the path to this "Power On/Off Script" on the pCP Squeezelite Settings page.
    # https://github.com/mvp/uhubctl#raspberry-pi-b2b3b
    #----------------------------------------------------------------------------------------
    # squeezelite -S /home/tc/usb-power-on-off.sh
    # 
    # squeezelite sets $1 to:
    #	0: off
    #	1: on
    #----------------------------------------------------------------------------------------
    NOW=$(date +"%m-%d-%Y %T")
    echo "---  $NOW ---" >>/tmp/powerlog.txt
    echo "Args: " "$@" >>/tmp/powerlog.txt
    case $1 in
        0) echo "Arg dollar 1 value 0 " >>/tmp/powerlog.txt ;;
        1) echo "Arg dollar 2 value 1 " >>/tmp/powerlog.txt ;;
    esac
    
    echo "---- End run ---- " >>/tmp/powerlog.txt
    Toggling power button on WebUI for player
    Code:
    ---  11-15-2020 11:49:12 ---
    Args:  0
    Arg dollar 1 value 0 
    ---- End run ---- 
    ---  11-15-2020 11:49:12 ---
    Args:  1
    Arg dollar 2 value 1 
    ---- End run ---- 
    ---  11-15-2020 11:49:13 ---
    Args:  0
    Arg dollar 1 value 0 
    ---- End run ---- 
    ---  11-15-2020 11:49:13 ---
    Args:  1
    Arg dollar 2 value 1 
    ---- End run ----
    I am using squeezelite v1.97-1282-pCP
    Running -S /home/tc/myscript.sh doesn't work from command line. I see "-sh: -S: not found"
    Adding it as a script in pCP also doesn't seem to do anything. Maybe my scripts aren't running for some reason.

  8. #28
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,137
    Quote Originally Posted by slartibartfast View Post
    I am using squeezelite v1.97-1282-pCP
    Running -S /home/tc/myscript.sh doesn't work from command line. I see "-sh: -S: not found"
    Adding it as a script in pCP also doesn't seem to do anything. Maybe my scripts aren't running for some reason.
    You don't show your command line

    The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/bin/sh"

    There is a pcp extension called bash.tcz whic may provide "/bin/bash "which may also then create a link to "/bin/sh"

    For example if I change the first line on my system to "#!/bin/badshell" I get the following message
    Code:
    sh:  1:  /home/pi/myscript.sh:  not found
    Last edited by bpa; 2020-11-15 at 13:06. Reason: Correct shell paths

  9. #29
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by bpa View Post
    You don't show your command line

    The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/usr/sh"

    There is a pcp extension called bash.tcz whic may provide "/usr/bash "which may also then create a link to "/usr/sh"

    For example if I change the first line on my system to "!/usr/badshell" I get the following message
    Code:
    sh:  1:  /home/pi/myscript.sh:  not found
    I found a forum post saying that pCP comes with sh. Is that a bash alternative?

    Sent from my Pixel 3a using Tapatalk

  10. #30
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,246
    Quote Originally Posted by bpa View Post
    You don't show your command line

    The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/usr/sh"

    There is a pcp extension called bash.tcz whic may provide "/usr/bash "which may also then create a link to "/usr/sh"

    For example if I change the first line on my system to "!/usr/badshell" I get the following message
    Code:
    sh:  1:  /home/pi/myscript.sh:  not found
    If I run
    /home/tc/my script.sh
    without the -S
    I get
    /home/tc/my script.sh: line 17: syntax error: unexpected word (expecting "in")

    Sent from my Pixel 3a using Tapatalk

Tags for this Thread

Posting Permissions

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