Kersul
Kersul

Reputation: 134

Run .rb (Ruby) file on a Shell Script

I created a shell script to automate some processes, something like that:

#!/bin/bash
ruby RubyFile.rb

But when I run this script, I get this error:

ruby(2882): Operation not permitted

Any one knows what the hell is this?

Upvotes: 4

Views: 9865

Answers (2)

Oto Brglez
Oto Brglez

Reputation: 4193

I use this when I want want to run Ruby code "as executable".

#!/usr/bin/env ruby

And then chmod the script.

chmod +x script.rb

And run it

./script.rb

I suggest usage of env because running a command through /usr/bin/env has the benefit of looking for whatever the default version of the program is in your current environment.

Upvotes: 11

wallenborn
wallenborn

Reputation: 4273

Why so complicated? Why not just

#!/usr/bin/ruby

or wherever your ruby is?

Upvotes: 0

Related Questions