I am attempting to write a very basic Bash script that will accomplish the same thing as this command line:
cvlc \
'rtsp://192.168.0.66/cam/realmonitor?channel=1&subtype=0&authbasic=xxxxxxxxx?tcp' \
--sout file/mp4:/mnt/recordings/camera16_2014_10_03_13.mp4 \
--run-time=60 vlc://quit
Entering this into the command line works and I get the expected 60 second MP4 file. Putting this into a bash script, I cannot seem to get all of the arguments passed to VLC correctly.
#!/bin/bash
camname="CAMERA16"
token="_"
ipadd="192.168.0.66"
runtime="60"
cvlc "rtsp://$ipadd/cam/realmonitor?channel=1&subtype=0&authbasic=xxxxxxxxx?tcp --sout file/mp4:/mnt/recordings/$camname$token$(date +$Y_%m_%d_$H_$M).mp4 --run-time=$runtime vlc://quit"
Running this script launches VLC, not headless, and ignores the other arguments. It does not write to a file and it never quits. It simply connects VLC to the stream and plays the stream.
I have tried several different ways of quoting the arguments with no success. All suggestions appreciated.