Bash Script Exits with code 127, zsh script doesn't

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I was playing around with ffmpeg tonight, trying to have Hazel use it through a shell script to do some stuff, and I ran into a bit of weirdness. Whenever I would try to call ffmpeg using sh or bash, the script would fail with an exit code 127. This happened both with just ffmpeg and the full path specification. The even weirder part is that just for kicks I switched to zsh and everything worked just fine.

Has anyone observed similar behaviour? Any suggestions on which dark corners of bash I should start poking my nose into?

Thanks

Phae
Vegans With Typewriters
phae_girl
 
Posts: 8
Joined: Mon Oct 15, 2012 1:57 pm

A quick search tells me that exit 127 means that ffmpeg is installed in the correct directory. I'd suggest updating ffpeg and installing in the suggested location.

Barring that, check the logs for Hazel to find additional error information. Post what you find.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Doing a whereis under bash for ffmpeg returns nothing. Trying with where under zsh returns /usr/local/bin/ffmpeg, which seemed reasonable. I did another install off ffmpeg using homebrew (brew install ffmpeg --use-clang) and everything installed fine. I checked again under bash with whereis ffmpeg and still nothing. where ffmpeg under zsh returned /usr/local/bin/ffmpeg again.

I suspect that something is awry in my my $PATH settings, but I can't for the life of me figure out why one shell sees it and the other one doesn't. I know that I can just use zsh and things will work, but I'm in it for the sport now.

- Phae
phae_girl
 
Posts: 8
Joined: Mon Oct 15, 2012 1:57 pm

Well, whereis uses hardcoded paths (I'm pretty sure), so its less likely to find a binary installed by a third party. Have you been able to find out what exit code 127 is?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

According to The Linux Documentation Project, a script exit code of 127 is "Command Not Found". A little more poking around showed that the locate database didn't exist, so I created it and threw a symlink in /usr/bin/ for good measure. Hmm…I wonder if there is a permissions issue.

- Phae
phae_girl
 
Posts: 8
Joined: Mon Oct 15, 2012 1:57 pm

Except for shell built-ins, any commands you call should have a full path to the command instead of relying on any environment variables. There may be another command you are invoking that isn't fully specified or one of the commands is calling something, relying on environment variables.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Eventually I did mess around with it again and made it work specifying the full path for ffmpeg. I put it off as just general bash flakiness. Oh, and the command that I was looking for to reveal the path to ffmpeg was which. I can't explain it, but I learned a whole bunch of stuff that will come in handy in the future.
phae_girl
 
Posts: 8
Joined: Mon Oct 15, 2012 1:57 pm


Return to Support