0

I'm trying to run a script after curling it, but with an option -- I get the error: /usr/bin/install: /usr/bin/install: cannot execute binary fil

curl https://raw.github.com/gist/2513225/a39232a94b25741ddb25e15755bddd5d71999b85/give-tourettes.sh | sh install

What syntax is wrong? Just some Friday shenanigans...

1 Answer 1

1

Apparently, what curl sends to its standard output isn't acceptable to sh. If I had to guess, the first line of the file is #!/bin/bash\r where the \r is a carriage return (CR), and the system can't find a file with the CR in the name. (And the error report is confusing because the CR spoils the display.)

Maybe you should pipe the output through tr -d '\015' before submitting it to the shell.

URL=https://raw.github.com/gist/2513225/a39232a94b25741ddb25e15755bddd5d71999b85/give-tourettes.sh
curl "$URL" |
tr -d '\015' |
sh install

See: bash: injecting variable into string adds extra \r for a related issue.

Against this hypothesis: sh install tries to run the file install in the current directory as a shell script. That may not work. Did you mean to pipe it to just sh to execute the tourettes.sh? Or are you expecting install to read its standard input (and if so, why)?

The 'lose the carriage return' advice is partially relevant; you don't want CR in the data, but it may not be the only, or even the main, issue here.

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

3 Comments

The script is self-containted -- ./give-tourettes.sh is what the cronjob runs, ./give-tourettes.sh install installs the cronjob.
Me thinks I should just reverse it :) Make cron execute with a param.
You would need to save the file to disk (and might need to deal with CRLF line endings). Then you could run sh give-tourettes.sh install to install it. As it stands, though, sh install will try to run something called install in the current directory, with (in effect) give-tourettes.sh as standard input (and not as a file). Were it me, I'd want the file on disk anyway.

Your Answer

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