1

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.

0

1 Answer 1

1

Those need to be separate arguments to the cvlc command. By putting them all in one big double-quoted string, you turn them into a single argument, which won't work. Put each of the arguments in its own set of double-quotes; don't put the spaces inside the quotes:

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

I used quoted newlines to split across multiple lines for legibility; it can also be just one long line without the \s.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.