Results 1 to 6 of 6

Thread: Script returning sh errors

  1. #1
    Join Date
    May 2008
    Beans
    6

    Script returning sh errors

    I have a script I have been trying to make. Right now it is just a manual execution but sooner. I do want it to run on the machine startup as well.

    When I execute the script it return the following:
    Code:
    -bash: root/vlc: /bin/sh^M: bad interpreter: No such file or directory
    Here is my script:
    Code:
    #!/bin/sh
    
    set -e
    
    . /lib/lsb/init-functions
    
    DAEMON=/usr/bin/vlc
    EXDAEMON=/usr/bin/vlc $2 -L
    
    test -x $DAEMON || exit 0
    
    case "$1" in
      start)
        log_begin_msg "Starting VLC Media Player"
        start-stop-daemon --start --background -m --pidfile /var/run/vlc.pid --exec $EXDAEMON && log_end_msg 0 || log_end_msg 1
        ;;
      stop)
        log_begin_msg "Stopping VLC Media Player"
        start-stop-daemon --stop --pidfile /var/run/vlc.pid --oknodo --exec $DAEMON && log_end_msg 0 || log_end_msg 1
        rm -f /var/run/vlc.pid
        ;;
      restart)
        $0 stop
        $0 start
        ;;
      *)
        log_success_msg "Usage: vlc {start|stop|restart}"
        exit 1
        ;;
    esac
    
    exit 0
    Anyone see what I have done wrong?

  2. #2
    Join Date
    Apr 2008
    Location
    Phoenix, AZ
    Beans
    1,393
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Script returning sh errors

    "/bin/sh^M"


    How was the file created? It looks like you managed to put a control character in that line, which is keeping it from finding the proper interpreter.

  3. #3
    Join Date
    May 2008
    Beans
    6

    Re: Script returning sh errors

    I typed it all out in a program called Crimson Editor on my desktop. then inside a ssh window i created the file with the editor command and just pasted the script in line by line.

  4. #4
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Script returning sh errors

    Hmm... Looks like you created a DOS file in a UNIX environment...

    Make a backup of the file, and run this command in the file location.
    Code:
    sed -i -e 's/^M$//g' scriptname.sh
    where scriptname.sh is the name of the file.

    Regards
    Iain
    Last edited by ibuclaw; May 27th, 2008 at 04:39 PM.

  5. #5
    Join Date
    May 2008
    Beans
    6

    Re: Script returning sh errors

    Ty that works, but now there other problem related to vlc, but i will take those to the vlc forums.

  6. #6
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Script returning sh errors

    And if you are curious as to how to reverse it. (Re-produce the error you got)

    Code:
    sed -i -e "s/$/`echo -e \\\r`/g" scriptname.sh
    Regards
    Iain

Bookmarks

Posting Permissions

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