Home of the Squeezebox™ & Transporter® network music players.
Page 4 of 8 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 75
  1. #31
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,352
    Quote Originally Posted by slartibartfast View Post
    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")
    When no argument is provided, the argument $1 is evaluated to blank/empty so the line to be executed is
    Code:
    case in
    Anything in the powerlog.txt file ?

    I think it has executed (and so there will be a line of text in powerlog) but is invalid as there has to be a value between "case" and "in"

    You must supply a non blank argument.

    /home/tc/myscript.sh 1
    /home/tc/myscript.sh 2
    /home/tc/myscript.sh 0

  2. #32
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by bpa View Post
    When no argument is provided, the argument $1 is evaluated to blank/empty so the line to be executed is
    Code:
    case in
    Anything in the powerlog.txt file ?

    I think it has executed (and so there will be a line of text in powerlog) but is invalid as there has to be a value between "case" and "in"

    You must supply a non blank argument.

    /home/tc/myscript.sh 1
    /home/tc/myscript.sh 2
    /home/tc/myscript.sh 0
    Running sh /home/tc/myscript.sh 1 gives the same response.
    I really don't know much about pCP, why do I need to add "sh" before the path to the script?

  3. #33
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by bpa View Post
    When no argument is provided, the argument $1 is evaluated to blank/empty so the line to be executed is
    Code:
    case in
    Anything in the powerlog.txt file ?

    I think it has executed (and so there will be a line of text in powerlog) but is invalid as there has to be a value between "case" and "in"

    You must supply a non blank argument.

    /home/tc/myscript.sh 1
    /home/tc/myscript.sh 2
    /home/tc/myscript.sh 0
    Powerlog.txt has a question mark next to it and doesn't seem to exist

  4. #34
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,352
    Quote Originally Posted by slartibartfast View Post
    Running sh /home/tc/myscript.sh 1 gives the same response.
    I really don't know much about pCP, why do I need to add "sh" before the path to the script?
    This is not about pcp - this is Linux and shell scripts.

    The name of the file containing the shell script is myscript.sh

    It is usual to use the file name extension ".sh" to denote a shell script in the same way a Perl file has ".pl"

    The shell script is usually executable (i.e. x in permissions, to add use chmod +x myscript.sh )

    If the file is not executable - then you have to gives command to execute the file
    sh myscript.sh
    perl myperlfile.pl

    If the first line of the file starts with "#!", it indicates specifically the file name of shell script interpreter (or other program) that should be run (e.g. /bin/sh, /bin/bash) to process the file.

    edit:

    Just to check about "sh" on pcp.

    does whereis command work ?

    if so try
    whereis sh
    Last edited by bpa; 2020-11-15 at 13:04. Reason: correct shell paths

  5. #35
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by bpa View Post
    This is not about pcp - this is Linux and shell scripts.

    The name of the file containing the shell script is myscript.sh

    It is usual to use the file name extension ".sh" to denote a shell script in the same way a Perl file has ".pl"

    The shell script must also be executable (i.e. x in permissions, to add use chmod +x myscript.sh )
    I made it executable by changing permissions in WinSCP so I assume that is the same as running chmod.

  6. #36
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,352
    Quote Originally Posted by slartibartfast View Post
    I made it executable by changing permissions in WinSCP so I assume that is the same as running chmod.
    Always check by doing a "ls -l" on the file. Maybe "stat /home/tc/myscript.sh" would also work - not sure about pcp.

  7. #37
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by bpa View Post
    Always check by doing a "ls -l" on the file. Maybe "stat /home/tc/myscript.sh" would also work - not sure about pcp.
    ls -l confirms myscript.sh has the same permissions as the bundled scripts
    -rwxr-xr-x

    Sent from my Pixel 3a using Tapatalk

  8. #38
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    4,012
    Everything works as expected in pCP7.

    Did you create the script on a Windows PC?

    Run

    dos2unix /home/tc/myscript.sh
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  9. #39
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by paul- View Post
    Everything works as expected in pCP7.

    Did you create the script on a Windows PC?

    Run

    dos2unix /home/tc/myscript.sh
    I did use windows but I used notepad++ and I can't even get powerscript.sh to run.

  10. #40
    Senior Member
    Join Date
    Jan 2010
    Location
    Hertfordshire
    Posts
    6,634
    Quote Originally Posted by paul- View Post
    Everything works as expected in pCP7.

    Did you create the script on a Windows PC?

    Run

    dos2unix /home/tc/myscript.sh
    If it matters I am only running pCP as a player.

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
  •