hevilp
Posts: 64
Joined: Sun Sep 09, 2012 6:13 pm

simple bash script not working right

Tue Apr 28, 2015 5:55 pm

Hi, I am using this script:

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:          Aufnahmescript
# Required-Start: $autofs
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Kurze Beschreibung
# Description:       Bechreibung
### END INIT INFO


#Switch case fuer den ersten Parameter
case "$1" in
    start)
                #Aktion wenn start aufgerufen wird
                datum=`date +%Y-%m-%d-%H-%M`
                raspivid -o /mnt/cam/$datum.h264 -t 0
        echo "Starte meinScript"
        ;;

    stop)
                #Aktion wenn stop aufgerufen wird
        killall raspivid
        echo "Stoppe meinScript"
        ;;

    restart)
                #Aktion wenn restart aufgerufen wird
                datum=`date +%Y-%m-%d-%H-%M`
                killall raspivid && raspivid -o /mnt/cam/$datum.h264 -t 0

        echo "Restarte meinScript"
        ;;
        *)
                #Default Aktion wenn start|stop|restart nicht passen
                echo "(start|stop|restart)"
                ;;
esac

exit 0
I want to start this script with the boot (as last).
The script is started, but the file is not saved.
The location, where I want the outputfile is mounted with autofs (nfs share)

The video is show, but there is no file written, why?
if I log in, stop and restart the script all is fine. Only with the boot up the file is not written like it should be.

Can u help me

User avatar
PeterO
Posts: 5029
Joined: Sun Jul 22, 2012 4:14 pm

Re: simple bash script not working right

Tue Apr 28, 2015 6:11 pm

What is mounted on /mnt ?
Can root write to it ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

hevilp
Posts: 64
Joined: Sun Sep 09, 2012 6:13 pm

Re: simple bash script not working right

Tue Apr 28, 2015 6:12 pm

root can write, when i stop the it, and run it when the user "pi" is logged in, the file is written. -> the mount is succesfull

Return to “General programming discussion”