1

When I run sudo fswebcam --png 9 -r 640x480 /var/www/image.jpg on my raspberry pi, it works fine.

If I add --banner-colour #ff0000 to it, like this:

sudo fswebcam --banner-colour #ff0000 --png 9 -r 640x480 /var/www/image.jpg

It tells me that my usage is wrong. Why is that argument not working?

Phil B.
  • 5,053
  • 17
  • 30
Pikamander2
  • 359
  • 3
  • 10

2 Answers2

2

I believe sudo treats a plain # (hash or pound) character as a comment. You need to escape this character to make it work, like so sudo fswebcam --banner-colour \#ff0000 --png 9 -r 640x480 /var/www/image.jpg.

I have not tried this with fswebcam, but on my Ubuntu desktop I did the following tests:

$ sudo echo #ff0000

$ sudo echo "#ff0000"
#ff0000
$ sudo echo \#ff0000
#ff0000
$ sudo echo #;echo "hello"

$ _

Which seems to support my answer.

 

Pikamander2
  • 359
  • 3
  • 10
Phil B.
  • 5,053
  • 17
  • 30
1

Phil's solution worked for me. I wanted to change the line colour as well, so I used:

sudo fswebcam --banner-colour: \#000000 --line-colour \#ffffff --png 9 -r 640x480 /var/www/image.jpg

That worked fine on its own, but when I tried to combine it with watch, I was encountering the same error, despite the hashtags being escaped.

After some Googling, I was able to fix that problem by putting double quotes around all of the code that was being given to watch.

Here's the final code that I used:

watch -n10 "sudo fswebcam --banner-colour: \#000000 --line-colour \#ffffff --png 9 -r 640x480 /var/www/image.jpg"
Pikamander2
  • 359
  • 3
  • 10