0

When I try to run a command on a remote host

ssh [email protected] "fswebcam -d /dev/video0 --save -" > img1

I always get at the top of the img1 file mixed in

^]kfswebcam -r 1280x960 -d /dev/video0 --save -\ÿØÿàJFIFÿþ>CREATOR: gd-jp

Which causes the file to no longer be a valid JPEG image

3 Answers 3

1

I found the issue.
It's in the fish shell, when I run /bin/bash ssh [email protected] "fswebcam -d /dev/video0 --save -" > img1 it works perfectly fine.
No mixed up headers in the jpeg image

1
  • I was wondering if it was the shell... Makes since Mar 23, 2014 at 23:38
0

This seems to be some echo configuration on the example.com host. I just tested with ssh localhost date and it will just print the date without any echo of the date command. Try to confirm this by running date and check if that also gets a first line of echo.

Try to temporarily disable files like .bashrc, .profile, etc by renaming or moving out of the home directory and see if you still get echo. Does changing the login shell for user to /bin/sh make any difference?

2
  • No, running date is fine. It's only when it's being outputted through pipe it seems. Which is very odd but also indicates it might be my osx behaving odd
    – Botto
    Mar 23, 2014 at 23:33
  • Any pipe? What about ssh localhost date | cat?.
    – hlovdal
    Mar 23, 2014 at 23:44
0

A rather roundabout way of doing it, but you could use:

ssh [email protected] "fswebcam -d /dev/video0 --save -"  | tail -n +2 > img1
4
  • sed 1d could alternatively be used instead of the head command.
    – hlovdal
    Mar 23, 2014 at 23:26
  • Won't work - using head -n -1 will get rid of the last line of the file, not the first. You want to do this: ssh [email protected] "fswebcam -d /dev/video0 --save -" | tail -n +2 > img1 EDIT: @hlovdal is correct as well.
    – user55325
    Mar 23, 2014 at 23:26
  • @user55325 Oops! Thanks for pointing that out! Mar 23, 2014 at 23:27
  • If it had only been that easy, unfortunately it's mixed in. I've updated the question
    – Botto
    Mar 23, 2014 at 23:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .